Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/libstd/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,13 @@ impl<'self> StrSlice<'self> for &'self str {
else if needle_len > self_len { false }
else { match_at(*self, needle, 0u) }
}
/// Returns true if `needle` is a prefix of the string, starting at `begin`.
fn starts_with_at<'a>(&self, needle: &'a str, begin: uint) -> bool {
let (self_len, needle_len) = (self.len(), needle.len());
if needle_len == 0u { true }
else if begin + needle_len > self_len { false }
else { match_at(*self, needle, begin) }
}
/// Returns true if `needle` is a suffix of the string.
fn ends_with(&self, needle: &str) -> bool {
let (self_len, needle_len) = (self.len(), needle.len());
Expand Down