pub struct Fix {
pub range: Range<usize>,
pub replacement: String,
pub additional_edits: Vec<Fix>,
}Expand description
One atomic fix attached to a LintWarning.
range/replacement describe the primary edit. additional_edits
carries any paired edits that must apply together with the primary one
for the result to be a valid document — for example, MD054’s conversion
of an inline link to a reference style produces the in-place link rewrite
and a reference-definition append at end-of-file; applying only one
half would leave a dangling reference.
All fix consumers (the LSP code-action layer, CLI counters, the
apply_warning_fixes helper) treat the primary edit and the
additional_edits as a single unit. The field is empty by default so
rules that only need a single-location fix can keep using
Fix::new(range, replacement); only rules that need multi-location
atomicity populate it via Fix::with_additional_edits(...).
additional_edits is intentionally a flat Vec<Fix> — nesting beyond
one level isn’t needed today and would complicate the apply contract.
Apply order is “primary first, then additional in their declared order”
when offsets are non-overlapping; consumers that batch multiple fixes
across warnings still sort by range.start descending so earlier offsets
remain valid as later edits mutate the buffer.
Fields§
§range: Range<usize>§replacement: String§additional_edits: Vec<Fix>Edits applied atomically with the primary range/replacement pair.
Empty for the common single-edit case. See struct docs for semantics.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Fix
impl<'de> Deserialize<'de> for Fix
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Fix
Auto Trait Implementations§
impl Freeze for Fix
impl RefUnwindSafe for Fix
impl Send for Fix
impl Sync for Fix
impl Unpin for Fix
impl UnsafeUnpin for Fix
impl UnwindSafe for Fix
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