pub struct GrepMatch {
pub file_index: usize,
pub line_number: u64,
pub col: usize,
pub byte_offset: u64,
pub line_content: String,
pub match_byte_offsets: SmallVec<[(u32, u32); 4]>,
pub fuzzy_score: Option<u16>,
pub is_definition: bool,
pub context_before: Vec<String>,
pub context_after: Vec<String>,
}Expand description
A single content match within a file.
Fields§
§file_index: usizeIndex into the deduplicated files vec of the GrepResult.
line_number: u641-based line number.
col: usize0-based byte column of first match start within the line.
byte_offset: u64Absolute byte offset of the matched line from the start of the file. Can be used by the preview to seek directly without scanning from the top.
line_content: StringThe matched line text, truncated to MAX_LINE_DISPLAY_LEN.
match_byte_offsets: SmallVec<[(u32, u32); 4]>Byte offsets (start, end) within line_content for each match.
Stack-allocated for the common case of ≤4 spans per line.
fuzzy_score: Option<u16>Fuzzy match score from neo_frizbee (only set in Fuzzy grep mode).
is_definition: boolWhether the matched line looks like a definition (struct, fn, class, etc.). Computed at match time so output formatters don’t need to re-scan.
context_before: Vec<String>Lines before the match (for context display). Empty when context is 0.
context_after: Vec<String>Lines after the match (for context display). Empty when context is 0.
Implementations§
Source§impl GrepMatch
impl GrepMatch
Sourcepub fn trim_leading_whitespace(&mut self)
pub fn trim_leading_whitespace(&mut self)
Strip leading whitespace from line_content and all context lines,
adjusting col and match_byte_offsets so highlights remain correct.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GrepMatch
impl RefUnwindSafe for GrepMatch
impl Send for GrepMatch
impl Sync for GrepMatch
impl Unpin for GrepMatch
impl UnsafeUnpin for GrepMatch
impl UnwindSafe for GrepMatch
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<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 more