Skip to main content

Change

Struct Change 

Source
pub struct Change<'h, S = &'h str> { /* private fields */ }
Expand description

A change in a buffer, with a start, taken text, and added text

If you acquired this Change from a BufferTracker::parts call, you need not worry about adding it to the ranges that need to be updated, as that has already been done.

Implementations§

Source§

impl Change<'static, String>

Source

pub fn new(edit: impl ToString, range: Range<Point>, text: &Text) -> Self

Returns a new Change.

Source

pub fn as_ref(&self) -> Change<'_, &str>

Returns a copyable Change

Source

pub fn try_merge(&mut self, older: Self)

In this function, it is assumed that self happened after newer

If the merger fails, the older Change will be returned;

Source§

impl<'h> Change<'h>

Source

pub fn to_string_change(&self) -> Change<'static, String>

Creates a Change<String> from a Change<&str>

Source

pub fn str_insert(added_str: &'h str, start: Point) -> Self

Returns a new copyable Change from an insertion.

Source§

impl<'s, S: Borrow<str>> Change<'s, S>

Source

pub fn reverse(self) -> Self

Returns a reversed version of this Change

Source

pub fn line_range(&self, strs: &Strs) -> Range<Point>

Gets a Range<Point>, from the start to the end of the affected lines

For example, if you make an edit that transforms lines 1..=3 to lines 1..=5, this function will return a Range that starts at the beginning of line 1, and ends at the end of line 5.

§Note

This end of this range will come after the last \n, which means that, in that example, said point would have a Point::line value equal to 6, not 5, since it represents both the end of line 5, and the beginning of line 6.

Source

pub fn start(&self) -> Point

The Point at the start of the change

Source

pub fn taken_end(&self) -> Point

Returns the end of the Change, before it was applied

Source

pub fn added_end(&self) -> Point

Returns the end of the Change, after it was applied

Source

pub fn taken_range(&self) -> Range<Point>

Returns the taken Range

Source

pub fn added_range(&self) -> Range<Point>

Returns the added Range

Source

pub fn added_str(&self) -> &str

The text that was taken on this Change

Source

pub fn taken_str(&self) -> &str

The text that was added by this Change

Source

pub fn shift(&self) -> [i32; 3]

The total shift caused by this Change

Trait Implementations§

Source§

impl<'de, Context> BorrowDecode<'de, Context> for Change<'static, String>

Source§

fn borrow_decode<D: BorrowDecoder<'de, Context = Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>

Attempt to decode this type with the given BorrowDecode.
Source§

impl<'h, S: Clone> Clone for Change<'h, S>

Source§

fn clone(&self) -> Change<'h, S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'s, S: Debug> Debug for Change<'s, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Context> Decode<Context> for Change<'static, String>

Source§

fn decode<D: Decoder<Context = Context>>( decoder: &mut D, ) -> Result<Self, DecodeError>

Attempt to decode this type with the given Decode.
Source§

impl<'h, S: Default> Default for Change<'h, S>

Source§

fn default() -> Change<'h, S>

Returns the “default value” for a type. Read more
Source§

impl Encode for Change<'static, String>

Source§

fn encode<E: Encoder>(&self, encoder: &mut E) -> Result<(), EncodeError>

Encode a given type.
Source§

impl<'h, S: Ord> Ord for Change<'h, S>

Source§

fn cmp(&self, other: &Change<'h, S>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'h, S: PartialEq> PartialEq for Change<'h, S>

Source§

fn eq(&self, other: &Change<'h, S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'h, S: PartialOrd> PartialOrd for Change<'h, S>

Source§

fn partial_cmp(&self, other: &Change<'h, S>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'h, S: Copy> Copy for Change<'h, S>

Source§

impl<'h, S: Eq> Eq for Change<'h, S>

Source§

impl<'h, S> StructuralPartialEq for Change<'h, S>

Auto Trait Implementations§

§

impl<'h, S> Freeze for Change<'h, S>
where S: Freeze,

§

impl<'h, S> RefUnwindSafe for Change<'h, S>
where S: RefUnwindSafe,

§

impl<'h, S> Send for Change<'h, S>
where S: Send,

§

impl<'h, S> Sync for Change<'h, S>
where S: Sync,

§

impl<'h, S> Unpin for Change<'h, S>
where S: Unpin,

§

impl<'h, S> UnsafeUnpin for Change<'h, S>
where S: UnsafeUnpin,

§

impl<'h, S> UnwindSafe for Change<'h, S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.