MCPcopy Create free account
hub / github.com/douchuan/algorithm / is_less

Function is_less

src/sort/insert.rs:40–49  ·  view source on GitHub ↗

is v less than w, starting at d-th character

(v: &str, w: &str, d: usize)

Source from the content-addressed store, hash-verified

38
39/// is v less than w, starting at d-th character
40fn is_less(v: &str, w: &str, d: usize) -> bool {
41 for (a, b) in v.bytes().zip(w.bytes()).skip(d) {
42 match a.cmp(&b) {
43 Ordering::Less => return true,
44 Ordering::Equal => (),
45 Ordering::Greater => return false,
46 }
47 }
48 v.as_bytes().len() < w.as_bytes().len()
49}
50
51#[test]
52fn t_less() {

Callers 1

sort_dthFunction · 0.85

Calls 2

cmpMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected