MCPcopy Create free account
hub / github.com/SharpCoder/teensycore / partial_cmp

Method partial_cmp

src/system/strings.rs:127–152  ·  view source on GitHub ↗
(&self, other: &Self)

Source from the content-addressed store, hash-verified

125// This might be a bad idea... but it makes BTreeMap super useful
126impl 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

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected