Change

Struct Change 

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

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

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<'a> Change<'a>

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: &'a 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, bytes: &Bytes) -> 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<'s, S: Clone> Clone for Change<'s, S>

Source§

fn clone(&self) -> Change<'s, 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<'s, S: Default> Default for Change<'s, S>

Source§

fn default() -> Change<'s, 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<'s, S: Ord> Ord for Change<'s, S>

Source§

fn cmp(&self, other: &Change<'s, 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<'s, S: PartialEq> PartialEq for Change<'s, S>

Source§

fn eq(&self, other: &Change<'s, 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<'s, S: PartialOrd> PartialOrd for Change<'s, S>

Source§

fn partial_cmp(&self, other: &Change<'s, 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<'s, S: Copy> Copy for Change<'s, S>

Source§

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

Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<'s, S> UnwindSafe for Change<'s, 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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.