pub struct Preprocessor { /* private fields */ }Expand description
A stateful preprocessor, intended to be run on sequential lines of the same file.
The state tracks multi-line comments/strings best-effort. If the diff begins inside an existing comment/string, the preprocessor cannot infer that.
Implementations§
Source§impl Preprocessor
impl Preprocessor
pub fn new(opts: PreprocessOptions) -> Self
Sourcepub fn with_language(opts: PreprocessOptions, lang: Language) -> Self
pub fn with_language(opts: PreprocessOptions, lang: Language) -> Self
Create a new preprocessor with language-specific syntax support.
Sourcepub fn set_language(&mut self, lang: Language)
pub fn set_language(&mut self, lang: Language)
Set the language for this preprocessor and reset state.
pub fn reset(&mut self)
Sourcepub fn sanitize_line(&mut self, line: &str) -> String
pub fn sanitize_line(&mut self, line: &str) -> String
Returns a sanitized line where masked segments are replaced with spaces.
The output is the same length in bytes as the input.
Trait Implementations§
Source§impl Clone for Preprocessor
impl Clone for Preprocessor
Source§fn clone(&self) -> Preprocessor
fn clone(&self) -> Preprocessor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Preprocessor
impl RefUnwindSafe for Preprocessor
impl Send for Preprocessor
impl Sync for Preprocessor
impl Unpin for Preprocessor
impl UnsafeUnpin for Preprocessor
impl UnwindSafe for Preprocessor
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