pub struct Edit {
pub start_byte: usize,
pub old_end_byte: usize,
pub new_end_byte: usize,
pub start_position: Position,
pub old_end_position: Position,
pub new_end_position: Position,
}Expand description
Represents an edit to the source text
Fields§
§start_byte: usizeStart byte offset of the edit
old_end_byte: usizeEnd byte offset of the text being replaced (in old source)
new_end_byte: usizeEnd byte offset after the edit (in new source)
start_position: PositionStart position (line/column)
old_end_position: PositionOld end position before edit
new_end_position: PositionNew end position after edit
Implementations§
Source§impl Edit
impl Edit
Sourcepub fn new(
start_byte: usize,
old_end_byte: usize,
new_end_byte: usize,
start_position: Position,
old_end_position: Position,
new_end_position: Position,
) -> Edit
pub fn new( start_byte: usize, old_end_byte: usize, new_end_byte: usize, start_position: Position, old_end_position: Position, new_end_position: Position, ) -> Edit
Create a new edit
Sourcepub fn byte_shift(&self) -> isize
pub fn byte_shift(&self) -> isize
Calculate the byte shift caused by this edit
Sourcepub fn line_shift(&self) -> i32
pub fn line_shift(&self) -> i32
Calculate the line shift caused by this edit
Sourcepub fn affects_byte(&self, byte: usize) -> bool
pub fn affects_byte(&self, byte: usize) -> bool
Check if a byte position is affected by this edit
Sourcepub fn overlaps_range(&self, range: &Range) -> bool
pub fn overlaps_range(&self, range: &Range) -> bool
Check if a range overlaps with this edit
Sourcepub fn apply_to_position(&self, pos: Position) -> Option<Position>
pub fn apply_to_position(&self, pos: Position) -> Option<Position>
Apply this edit to a position
Sourcepub fn apply_to_range(&self, range: &Range) -> Option<Range>
pub fn apply_to_range(&self, range: &Range) -> Option<Range>
Apply this edit to a range
Trait Implementations§
impl StructuralPartialEq for Edit
Auto Trait Implementations§
impl Freeze 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