pub struct HighlightedText<S> { /* private fields */ }Expand description
Represents text which was highlighted by the TextHighlighter.
Display implementations come in the form of Self::display_plain, Self::display_subs
and Self::display_raw.
Implementations§
Source§impl<S> HighlightedText<S>
impl<S> HighlightedText<S>
Source§impl<S: AsRef<str>> HighlightedText<S>
impl<S: AsRef<str>> HighlightedText<S>
pub fn ranges(&self) -> impl Iterator<Item = Range<usize>> + '_
Sourcepub fn pieces(&self) -> impl Iterator<Item = Piece<'_>> + '_
pub fn pieces(&self) -> impl Iterator<Item = Piece<'_>> + '_
Walk the text as a stream of marker-free chunks: Piece::Text for unhighlighted runs and
Piece::Match for each highlighted span.
Concatenating every chunk yields the same string as Self::display_plain, and the
Piece::Match chunks are exactly the spans Self::ranges reports. Empty chunks are
skipped.
Sourcepub fn lines(&self) -> impl Iterator<Item = HighlightedText<&str>> + '_
pub fn lines(&self) -> impl Iterator<Item = HighlightedText<&str>> + '_
Each line as its own highlighted text. A match never spans a newline, so every span stays within one line.
Sourcepub fn to_plain(&self) -> Plain<'_>
pub fn to_plain(&self) -> Plain<'_>
The marker-free text together with the byte range of every match within that text –
unlike Self::ranges, whose offsets index the raw, marker-bearing string.
Sourcepub fn display_plain(&self) -> impl Display + '_
pub fn display_plain(&self) -> impl Display + '_
Display the highlighted text, stripping away the highlight markers.
Sourcepub fn display_subs(&self, subs: [char; 2]) -> impl Display + '_
pub fn display_subs(&self, subs: [char; 2]) -> impl Display + '_
Display the highlighted text, replacing highlighted markers with subs.
Sourcepub fn display_raw(&self) -> impl Display + '_
pub fn display_raw(&self) -> impl Display + '_
Display the highlighted text as-is, including markers.
Trait Implementations§
Source§impl<S: Clone> Clone for HighlightedText<S>
impl<S: Clone> Clone for HighlightedText<S>
impl<S: Copy> Copy for HighlightedText<S>
Auto Trait Implementations§
impl<S> Freeze for HighlightedText<S>where
S: Freeze,
impl<S> RefUnwindSafe for HighlightedText<S>where
S: RefUnwindSafe,
impl<S> Send for HighlightedText<S>where
S: Send,
impl<S> Sync for HighlightedText<S>where
S: Sync,
impl<S> Unpin for HighlightedText<S>where
S: Unpin,
impl<S> UnsafeUnpin for HighlightedText<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for HighlightedText<S>where
S: UnwindSafe,
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
Source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
Source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
Source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
Source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
Source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EscapeNonPrintablePosixExt for T
impl<T> EscapeNonPrintablePosixExt for T
fn escape_non_printable(&self) -> Cow<'_, str>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 moreSource§impl<T> NormalizeDiacriticsExt for T
impl<T> NormalizeDiacriticsExt for T
Source§fn normalize_diacritics(&self) -> Cow<'_, str>
fn normalize_diacritics(&self) -> Cow<'_, str>
é -> e).