| 125 | // This might be a bad idea... but it makes BTreeMap super useful |
| 126 | impl PartialOrd for String { |
| 127 | fn partial_cmp(&self, other: &Self) -> Option<Ordering> { |
| 128 | let min_count; |
| 129 | if self.size() > other.size() { |
| 130 | min_count = other.size(); |
| 131 | } else { |
| 132 | min_count = self.size(); |
| 133 | } |
| 134 | |
| 135 | for idx in 0 .. min_count { |
| 136 | let left = self.get(idx).unwrap(); |
| 137 | let right = other.get(idx).unwrap(); |
| 138 | |
| 139 | if left == right { |
| 140 | continue; |
| 141 | } else { |
| 142 | return left.partial_cmp(&right); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | // They are the same up to this point |
| 147 | if self.size() > other.size() { |
| 148 | return Some(Ordering::Greater); |
| 149 | } else { |
| 150 | return Some(Ordering::Less); |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | |