|
1 | 1 | use std::borrow::Borrow;
|
| 2 | +use std::cmp; |
2 | 3 | use std::fmt;
|
3 | 4 | use std::hash::{Hash, Hasher};
|
4 | 5 | use std::mem;
|
@@ -281,10 +282,45 @@ impl<A: Array<Item=u8> + Copy> Clone for ArrayString<A> {
|
281 | 282 | fn clone(&self) -> ArrayString<A> {
|
282 | 283 | *self
|
283 | 284 | }
|
284 |
| - |
285 | 285 | fn clone_from(&mut self, rhs: &Self) {
|
286 | 286 | // guaranteed to fit due to types matching.
|
287 | 287 | self.clear();
|
288 | 288 | self.push_str(rhs).ok();
|
289 | 289 | }
|
290 | 290 | }
|
| 291 | + |
| 292 | +impl<A: Array<Item=u8>> PartialOrd for ArrayString<A> { |
| 293 | + fn partial_cmp(&self, rhs: &Self) -> Option<cmp::Ordering> { |
| 294 | + (**self).partial_cmp(&**rhs) |
| 295 | + } |
| 296 | + fn lt(&self, rhs: &Self) -> bool { **self < **rhs } |
| 297 | + fn le(&self, rhs: &Self) -> bool { **self <= **rhs } |
| 298 | + fn gt(&self, rhs: &Self) -> bool { **self > **rhs } |
| 299 | + fn ge(&self, rhs: &Self) -> bool { **self >= **rhs } |
| 300 | +} |
| 301 | + |
| 302 | +impl<A: Array<Item=u8>> PartialOrd<str> for ArrayString<A> { |
| 303 | + fn partial_cmp(&self, rhs: &str) -> Option<cmp::Ordering> { |
| 304 | + (**self).partial_cmp(rhs) |
| 305 | + } |
| 306 | + fn lt(&self, rhs: &str) -> bool { &**self < rhs } |
| 307 | + fn le(&self, rhs: &str) -> bool { &**self <= rhs } |
| 308 | + fn gt(&self, rhs: &str) -> bool { &**self > rhs } |
| 309 | + fn ge(&self, rhs: &str) -> bool { &**self >= rhs } |
| 310 | +} |
| 311 | + |
| 312 | +impl<A: Array<Item=u8>> PartialOrd<ArrayString<A>> for str { |
| 313 | + fn partial_cmp(&self, rhs: &ArrayString<A>) -> Option<cmp::Ordering> { |
| 314 | + self.partial_cmp(&**rhs) |
| 315 | + } |
| 316 | + fn lt(&self, rhs: &ArrayString<A>) -> bool { self < &**rhs } |
| 317 | + fn le(&self, rhs: &ArrayString<A>) -> bool { self <= &**rhs } |
| 318 | + fn gt(&self, rhs: &ArrayString<A>) -> bool { self > &**rhs } |
| 319 | + fn ge(&self, rhs: &ArrayString<A>) -> bool { self >= &**rhs } |
| 320 | +} |
| 321 | + |
| 322 | +impl<A: Array<Item=u8>> Ord for ArrayString<A> { |
| 323 | + fn cmp(&self, rhs: &Self) -> cmp::Ordering { |
| 324 | + (**self).cmp(&**rhs) |
| 325 | + } |
| 326 | +} |
0 commit comments