pub struct SpannedStr<'a, T> { /* private fields */ }Expand description
The immutable, borrowed equivalent of SpannedString.
Implementations§
Source§impl<'a, T> SpannedStr<'a, T>where
T: 'a,
impl<'a, T> SpannedStr<'a, T>where
T: 'a,
Sourcepub const fn new(source: &'a str, spans: &'a [IndexedSpan<T>]) -> Self
pub const fn new(source: &'a str, spans: &'a [IndexedSpan<T>]) -> Self
Creates a new SpannedStr from the given references.
Sourcepub fn spans<'b>(
&'b self,
) -> impl DoubleEndedIterator<Item = Span<'a, T>> + ExactSizeIterator<Item = Span<'a, T>> + 'bwhere
'a: 'b,
pub fn spans<'b>(
&'b self,
) -> impl DoubleEndedIterator<Item = Span<'a, T>> + ExactSizeIterator<Item = Span<'a, T>> + 'bwhere
'a: 'b,
Gives access to the parsed styled spans.
Sourcepub const fn spans_raw(&self) -> &'a [IndexedSpan<T>]
pub const fn spans_raw(&self) -> &'a [IndexedSpan<T>]
Returns a reference to the indexed spans.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Returns true if self is empty.
Can be caused by an empty source, or no span.
Sourcepub fn width(&self) -> usize
pub fn width(&self) -> usize
Returns the width taken by this string.
This is the sum of the width of each span.
Sourcepub fn from_spanned_text<'b, S>(text: &'b S) -> Selfwhere
S: SpannedText<S = IndexedSpan<T>>,
'b: 'a,
pub fn from_spanned_text<'b, S>(text: &'b S) -> Selfwhere
S: SpannedText<S = IndexedSpan<T>>,
'b: 'a,
Create a new SpannedStr by borrowing from a SpannedText.
Trait Implementations§
Source§impl<'a, T> Clone for SpannedStr<'a, T>
impl<'a, T> Clone for SpannedStr<'a, T>
Source§impl<'a, T: Debug> Debug for SpannedStr<'a, T>
impl<'a, T: Debug> Debug for SpannedStr<'a, T>
Source§impl<'a, T> From<&'a SpannedString<T>> for SpannedStr<'a, T>
impl<'a, T> From<&'a SpannedString<T>> for SpannedStr<'a, T>
Source§fn from(other: &'a SpannedString<T>) -> Self
fn from(other: &'a SpannedString<T>) -> Self
Converts to this type from the input type.
Source§impl<'a, T: Hash> Hash for SpannedStr<'a, T>
impl<'a, T: Hash> Hash for SpannedStr<'a, T>
Source§impl<'a, T: PartialEq> PartialEq for SpannedStr<'a, T>
impl<'a, T: PartialEq> PartialEq for SpannedStr<'a, T>
Source§impl<'a, T> SpannedText for SpannedStr<'a, T>where
T: 'a,
impl<'a, T> SpannedText for SpannedStr<'a, T>where
T: 'a,
Source§type S = IndexedSpan<T>
type S = IndexedSpan<T>
Type of span returned by
SpannedText::spans(). Read moreSource§fn spans(&self) -> &[IndexedSpan<T>]
fn spans(&self) -> &[IndexedSpan<T>]
Returns the spans for this text.
Source§fn as_ref(&self) -> SpannedTextRef<'_, Self>
fn as_ref(&self) -> SpannedTextRef<'_, Self>
Returns a
SpannedText by reference.impl<'a, T: Eq> Eq for SpannedStr<'a, T>
impl<'a, T> StructuralPartialEq for SpannedStr<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for SpannedStr<'a, T>
impl<'a, T> RefUnwindSafe for SpannedStr<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for SpannedStr<'a, T>where
T: Sync,
impl<'a, T> Sync for SpannedStr<'a, T>where
T: Sync,
impl<'a, T> Unpin for SpannedStr<'a, T>
impl<'a, T> UnwindSafe for SpannedStr<'a, T>where
T: RefUnwindSafe,
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.