pub struct Normalized {
pub text: String,
pub original_len: usize,
/* private fields */
}Expand description
Normalized text plus a map from each normalized byte offset back to the originating byte offset in the input (for reporting spans against the original text).
Fields§
§text: StringThe normalized, lowercased text (with any decoded base64 appended).
original_len: usizeByte length of the original input, used to clamp mapped spans.
Implementations§
Source§impl Normalized
impl Normalized
Sourcepub fn original_span(
&self,
norm_start: usize,
norm_end: usize,
) -> (usize, usize)
pub fn original_span( &self, norm_start: usize, norm_end: usize, ) -> (usize, usize)
Map a [start, end) span in normalized bytes back to a [start, end)
span in the ORIGINAL input bytes (best-effort; clamps to original_len).
norm_start maps to the original offset of the first normalized byte;
norm_end maps to the original offset just past the last covered byte.
An empty or inverted span collapses to a zero-width span at the mapped
start.
The returned span is for REPORTING only (it labels where in the original
a match occurred) and is best-effort: when the last covered original
character is multi-byte (e.g. a folded homoglyph), the end may land one
byte short of that character’s boundary. Callers must therefore treat
these as numeric markers and not assume &original[start..end] is a valid
UTF-8 slice — use a lossy/checked read if slicing.
Trait Implementations§
Source§impl Clone for Normalized
impl Clone for Normalized
Source§fn clone(&self) -> Normalized
fn clone(&self) -> Normalized
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Normalized
impl Debug for Normalized
impl Eq for Normalized
Source§impl PartialEq for Normalized
impl PartialEq for Normalized
Source§fn eq(&self, other: &Normalized) -> bool
fn eq(&self, other: &Normalized) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for Normalized
Auto Trait Implementations§
impl Freeze for Normalized
impl RefUnwindSafe for Normalized
impl Send for Normalized
impl Sync for Normalized
impl Unpin for Normalized
impl UnsafeUnpin for Normalized
impl UnwindSafe for Normalized
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<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
key and return true if they are equal.