pub struct Edit {
pub start: usize,
pub old_end: usize,
pub new_end: usize,
}Expand description
One replacement in a field’s text, in bytes: start..old_end of the text
before became start..new_end of the text after. The fields are
tree-sitter’s InputEdit byte fields.
Fields§
§start: usize§old_end: usize§new_end: usizeImplementations§
Source§impl Edit
impl Edit
Sourcepub fn between(before: &str, after: &str) -> Self
pub fn between(before: &str, after: &str) -> Self
The smallest edit that turns before into after: what they share at
either end is left out.
Sourcepub fn map(self, range: Range<usize>) -> Option<Range<usize>>
pub fn map(self, range: Range<usize>) -> Option<Range<usize>>
Where range of the text before lands in the text after. A range
wholly before the edit stays, one wholly after moves by the length the
edit added or took, one the edit falls inside grows or shrinks with it,
and one the edit cuts keeps the part it did not touch. None when the
edit took all of it.
Trait Implementations§
impl Copy for Edit
impl Eq for Edit
impl StructuralPartialEq for Edit
Auto Trait Implementations§
impl Forget for Edit
impl Freeze for Edit
impl Move for Edit
impl RefUnwindSafe for Edit
impl Send for Edit
impl Sync for Edit
impl Unpin for Edit
impl UnsafeUnpin for Edit
impl UnwindSafe for Edit
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
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<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
Compare self to
key and return true if they are equal.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> ⓘ
Converts
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> ⓘ
Converts
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