pub struct StrList { /* private fields */ }Expand description
An immutable, compact representation of a list of string slices.
StrList is the “frozen” counterpart to StrStack. It stores the same data
(a contiguous UTF-8 byte buffer plus a u32 boundary table) but uses boxed slices
instead of Vecs, shedding excess capacity.
Typically created by converting a finished StrStack via From<StrStack> or
by collecting an iterator of &str.
§Invariants
datais always valid UTF-8.endsvalues are monotonically non-decreasing and the last value does not exceeddata.len().
Implementations§
Source§impl StrList
impl StrList
Sourcepub fn get(&self, index: usize) -> Option<&str>
pub fn get(&self, index: usize) -> Option<&str>
Returns the segment at index, or None if out of bounds.
Sourcepub fn get_bounds(&self, index: usize) -> Option<(u32, u32)>
pub fn get_bounds(&self, index: usize) -> Option<(u32, u32)>
Returns the byte offset bounds (start, end) for the segment at index.
Sourcepub fn as_ref(&self) -> StrListRef<'_>
pub fn as_ref(&self) -> StrListRef<'_>
Returns a borrowed view over this list.
Sourcepub fn iter(&self) -> StrListIter<'_> ⓘ
pub fn iter(&self) -> StrListIter<'_> ⓘ
Returns an iterator over the string segments.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for StrList
Available on crate feature serde only.
impl<'de> Deserialize<'de> for StrList
Available on crate feature
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a> From<&'a StrList> for StrListRef<'a>
impl<'a> From<&'a StrList> for StrListRef<'a>
Source§impl<'a> FromIterator<&'a str> for StrList
impl<'a> FromIterator<&'a str> for StrList
Source§impl<'a> IntoIterator for &'a StrList
impl<'a> IntoIterator for &'a StrList
impl Eq for StrList
impl StructuralPartialEq for StrList
Auto Trait Implementations§
impl Freeze for StrList
impl RefUnwindSafe for StrList
impl Send for StrList
impl Sync for StrList
impl Unpin for StrList
impl UnsafeUnpin for StrList
impl UnwindSafe for StrList
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