pub struct StrSpan<'a> { /* private fields */ }Expand description
An immutable string slice.
Unlike &str contains a reference to the original string
and a span position.
Implementations
sourceimpl<'a> StrSpan<'a>
impl<'a> StrSpan<'a>
sourcepub fn from_substr(text: &str, start: usize, end: usize) -> StrSpan<'_>
pub fn from_substr(text: &str, start: usize, end: usize) -> StrSpan<'_>
Constructs a new StrSpan from substring.
sourcepub fn to_str(&self) -> &'a str
pub fn to_str(&self) -> &'a str
Returns a span slice.
A bit expensive, since Rust checks for char boundary.
sourcepub fn as_bytes(&self) -> &'a [u8] ⓘ
pub fn as_bytes(&self) -> &'a [u8] ⓘ
Returns a span slice as bytes.
The same as to_str but does not involve char boundary checking.
sourcepub fn slice_region(&self, start: usize, end: usize) -> StrSpan<'a>
pub fn slice_region(&self, start: usize, end: usize) -> StrSpan<'a>
Returns an underling string region as StrSpan.
Trait Implementations
sourceimpl<'a> PartialEq<StrSpan<'a>> for StrSpan<'a>
impl<'a> PartialEq<StrSpan<'a>> for StrSpan<'a>
impl<'a> Copy for StrSpan<'a>
impl<'a> StructuralPartialEq for StrSpan<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for StrSpan<'a>
impl<'a> Send for StrSpan<'a>
impl<'a> Sync for StrSpan<'a>
impl<'a> Unpin for StrSpan<'a>
impl<'a> UnwindSafe for StrSpan<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more