Fix Rope.starts_with. (#11739)
Co-authored-by: Rose Hogenson <rosehogenson@posteo.net>
This commit is contained in:
parent
9f93de5a4b
commit
5717aa8e35
1 changed files with 11 additions and 1 deletions
|
@ -51,7 +51,7 @@ impl<'a> RopeSliceExt<'a> for RopeSlice<'a> {
|
||||||
if len < text.len() {
|
if len < text.len() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
self.get_byte_slice(..len - text.len())
|
self.get_byte_slice(..text.len())
|
||||||
.map_or(false, |start| start == text)
|
.map_or(false, |start| start == text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,4 +137,14 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn starts_with() {
|
||||||
|
assert!(RopeSlice::from("asdf").starts_with("a"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ends_with() {
|
||||||
|
assert!(RopeSlice::from("asdf").ends_with("f"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue