pub struct ImmutableString { /* private fields */ }
Available on crate feature
source-tracking
only.Expand description
An immutable string that either
- References a source string in memory using a
'static
reference, - Owns a source string in memory.
- Owns a locked and memory mapped file from the disk.
This uses an Arc internally to make cloning cheap.
Implementations§
Source§impl ImmutableString
impl ImmutableString
Sourcepub fn line_starts(&self) -> Vec<usize>
pub fn line_starts(&self) -> Vec<usize>
Get a list of byte indices into this ImmutableString of the start of every line.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Get this ImmutableString as a str reference. This just calls AsRef::as_ref.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the length of this ImmutableString in bytes. See str::len.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if this ImmutableString is empty.
Trait Implementations§
Source§impl AsRef<str> for ImmutableString
impl AsRef<str> for ImmutableString
Source§impl Clone for ImmutableString
impl Clone for ImmutableString
Source§fn clone(&self) -> ImmutableString
fn clone(&self) -> ImmutableString
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for ImmutableString
impl RefUnwindSafe for ImmutableString
impl Send for ImmutableString
impl Sync for ImmutableString
impl Unpin for ImmutableString
impl UnwindSafe for ImmutableString
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more