Trait substring::Substring [−][src]
Provides a substring()
method.
The substring()
method obtains a string slice of characters within the range specified by
start_index
and end_index
.
Required methods
fn substring(&self, start_index: usize, end_index: usize) -> &str
[src]
Obtains a string slice containing the characters within the range specified by
start_index
and end_index
.
The range specified is a character range, not a byte range.
Implementors
impl Substring for str
[src]
Implements a substring()
method for str
.
Note that structs which implement Deref<Target=str>
(such as String
) will also have
access to this implementation.
#[must_use]fn substring(&self, start_index: usize, end_index: usize) -> &str
[src]
Obtain a slice of the characters within the range of start_index
and end_index
.
As this is by character index, rather than byte index, the temporal complexity of finding a substring is O(n), where n is the byte length of the string.
Example:
use substring::Substring; assert_eq!("foobar".substring(2,5), "oba");