Rope

Struct Rope 

Source
pub struct Rope<M>
where M: Measurable, [(); { _ }]: Sized,
{ /* private fields */ }
Expand description

A rope of elements that are Measurable.

The time complexity of nearly all edit and query operations on Rope<M> are worst-case O(log N) in the length of the rope. Rope<M> is designed to work efficiently even for huge (in the gigabytes) arrays of M.

In the examples below, a struct called Width will be used in order to demonstrate AnyRope’s features.

§Editing Operations

The primary editing operations on Rope<M> are insertion and removal of slices or individual elements. For example:

let mut rope = Rope::from_slice(&[
    Width(1),
    Width(2),
    Width(3),
    Width(0),
    Width(0),
    Width(2),
    Width(1),
]);
rope.remove_inclusive(6..8, usize::cmp);
rope.insert(6, Width(5), usize::cmp);

assert_eq!(
    rope,
    [Width(1), Width(2), Width(3), Width(5), Width(1)].as_slice()
);

§Query Operations

Rope<M> gives you the ability to query an element at any given index or measure, and the convertion between the two. You can either convert an index to a measure, or convert the measure at the start or end of an element to an index. For example:

let rope = Rope::from_slice(&[
    Width(0),
    Width(0),
    Width(1),
    Width(1),
    Width(2),
    Width(25),
    Width(0),
    Width(0),
    Width(1),
]);

// `start_measure_to_index()` will pick the first element that starts at the given index.
assert_eq!(rope.start_measure_to_index(0, usize::cmp), 0);
// `end_measure_to_index()` will pick the last element that still starts at the given index.
assert_eq!(rope.end_measure_to_index(0, usize::cmp), 2);
assert_eq!(rope.start_measure_to_index(2, usize::cmp), 4);
assert_eq!(rope.start_measure_to_index(3, usize::cmp), 4);
assert_eq!(rope.start_measure_to_index(16, usize::cmp), 5);
assert_eq!(rope.start_measure_to_index(29, usize::cmp), 6);

§Slicing

You can take immutable slices of a Rope<M> using measure_slice() or index_slice():

let mut rope = Rope::from_slice(&[
    Width(1),
    Width(2),
    Width(3),
    Width(0),
    Width(0),
    Width(2),
    Width(1),
]);
let measure_slice = rope.measure_slice(3..6, usize::cmp);
let index_slice = rope.index_slice(2..5);

assert_eq!(measure_slice, index_slice);

§Cloning

Cloning Rope<M>s is extremely cheap, running in O(1) time and taking a small constant amount of memory for the new clone, regardless of slice size. This is accomplished by data sharing between Rope<M> clones. The memory used by clones only grows incrementally as the their contents diverge due to edits. All of this is thread safe, so clones can be sent freely between threads.

The primary intended use-case for this feature is to allow asynchronous processing of Rope<M>s.

Implementations§

Source§

impl<M> Rope<M>
where M: Measurable, [(); { _ }]: Sized,

Source

pub fn new() -> Self

Creates an empty Rope<M>.

Source

pub fn from_slice(slice: &[M]) -> Self

Creates a Rope<M> from an M slice.

Runs in O(N) time.

Source

pub fn len(&self) -> usize

Total number of elements in Rope<M>.

Runs in O(N) time.

Source

pub fn is_empty(&self) -> bool

Returns true if the Rope<M> is empty.

Runs in O(N) time.

Source

pub fn measure(&self) -> M::Measure

Sum of all measures of in Rope<M>.

Runs in O(N) time.

Source

pub fn capacity(&self) -> usize

Total size of the Rope<M>’s buffer space.

This includes unoccupied buffer space. You can calculate the unoccupied space with Rope::capacity() - Rope::len(). In general, there will always be some unoccupied buffer space.

Runs in O(N) time.

Source

pub fn shrink_to_fit(&mut self)

Shrinks the Rope<M>’s capacity to the minimum possible.

This will rarely result in Rope::capacity() == Rope::len(). Rope<M> stores Ms in a sequence of fixed-capacity chunks, so an exact fit only happens for lists of a lenght that is a multiple of that capacity.

After calling this, the difference between capacity() and len() is typically under 1000 for each 1000000 M in the Rope<M>.

NOTE: calling this on a Rope<M> clone causes it to stop sharing all data with its other clones. In such cases you will very likely be increasing total memory usage despite shrinking the Rope<M>’s capacity.

Runs in O(N) time, and uses O(log N) additional space during shrinking.

Source

pub fn insert_slice( &mut self, measure: M::Measure, slice: &[M], cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, )

Inserts slice at measure.

Runs in O(L + log N) time, where N is the length of the Rope<M> and L is the length of slice.

§Panics

Panics if the measure is out of bounds (i.e. measure > Rope::measure()).

Source

pub fn insert( &mut self, measure: M::Measure, measurable: M, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, )

Inserts a single M at measure.

Runs in O(log N) time.

§Panics

Panics if the measure is out of bounds (i.e. measure > Rope::measure()).

Source

pub fn remove_inclusive( &mut self, range: impl MeasureRange<M>, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, )

Removes the slice in the given measure range.

Uses range syntax, e.g. 2..7, 2.., etc.

Runs in O(M + log N) time, where N is the length of the Rope<M> and M is the length of the range being removed.

The first removed M will be the first with a end measure sum greater than the starting bound if its measure() is greater than 0, or equal to the starting bound if its measure() is equal to 0.

The last removed M will be the first with a start measure sum greater than the ending bound if its measure() is greater than 0, or the last one with a start measure sum equal to the ending bound if its measure() is equal to 0.

In essence, this means the following:

  • A range starting between a M’s start and end measure sums will remove said M.
  • A range ending in the start of a list of 0 measure Ms will remove all of them.
  • An empty range that starts and ends in a list of 0 measure Ms will remove all of them, and nothing else. This contrasts with Rust’s usual definition of an empty range.
§Examples
let array = [
    Width(1),
    Width(2),
    Width(3),
    Width(0),
    Width(0),
    Width(2),
    Width(1),
];
let mut rope = Rope::from_slice(&array);

// Removing in the middle of `Width(3)`.
rope.remove_inclusive(5.., usize::cmp);

assert_eq!(rope, [Width(1), Width(2)].as_slice());
let array = [
    Width(1),
    Width(2),
    Width(3),
    Width(0),
    Width(0),
    Width(2),
    Width(1),
];
let mut rope = Rope::from_slice(&array);

// End bound coincides with a 0 measure list.
rope.remove_inclusive(1..6, usize::cmp);

assert_eq!(rope, [Width(1), Width(2), Width(1)].as_slice());
let array = [
    Width(1),
    Width(2),
    Width(3),
    Width(0),
    Width(0),
    Width(2),
    Width(1),
];
let mut rope = Rope::from_slice(&array);

// Empty range at the start of a 0 measure list.
rope.remove_inclusive(6..6, usize::cmp);

// Inclusively removing an empty range does nothing.
assert_eq!(
    rope,
    [Width(1), Width(2), Width(3), Width(2), Width(1)].as_slice()
);
§Panics

Panics if the start of the range is greater than the end, or if the end is out of bounds (i.e. end > self.measure()).

Source

pub fn remove_exclusive( &mut self, range: impl MeasureRange<M>, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, )

Same as remove_inclusive(), but keeps elements measure measure equal to 0 at the edges.

If the measure_range doesn’t cover the entire measure of a single M, then the removal does nothing.

§Examples
let array = [
    Width(1),
    Width(2),
    Width(3),
    Width(0),
    Width(0),
    Width(2),
    Width(1),
];
let mut rope = Rope::from_slice(&array);

// End bound coincides with a 0 measure list, which does not get removed.
rope.remove_exclusive(1..6, usize::cmp);

assert_eq!(
    rope,
    [Width(1), Width(0), Width(0), Width(2), Width(1)].as_slice()
);
let array = [
    Width(1),
    Width(2),
    Width(3),
    Width(0),
    Width(0),
    Width(2),
    Width(1),
];
let mut rope = Rope::from_slice(&array);

// Empty range at the start of a 0 measure list.
rope.remove_exclusive(6..6, usize::cmp);

// Exclusively removing an empty range does nothing.
assert_eq!(rope, array.as_slice());
let array = [
    Width(1),
    Width(2),
    Width(3),
    Width(0),
    Width(0),
    Width(2),
    Width(1),
];
let mut rope = Rope::from_slice(&array);

// Removing in the middle of `Width(3)`.
rope.remove_exclusive(5..6, usize::cmp);

// Exclusively removing in the middle of an element does nothing.
assert_eq!(rope, array.as_slice());
§Panics

Panics if the start of the range is greater than the end, or if the end is out of bounds (i.e. end > self.measure()).

Source

pub fn split_off( &mut self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Self

Splits the Rope<M> at measure, returning the right part of the split.

Runs in O(log N) time.

§Panics

Panics if the measure is out of bounds (i.e. measure > self.measure()).

Source

pub fn append(&mut self, other: Self)

Appends a Rope<M> to the end of this one, consuming the other Rope<M>.

Runs in O(log N) time.

Source

pub fn index_to_measure(&self, index: usize) -> M::Measure

Returns the measure sum at the start of the given index.

Notes:

Runs in O(log N) time.

§Panics

Panics if the index is out of bounds (i.e. index > Rope::len()).

Source

pub fn start_measure_to_index( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> usize

Returns an index, given a starting measure sum.

Runs in O(log N) time.

§Panics

Panics if the measure is out of bounds (i.e. measure > Rope::measure()).

Source

pub fn end_measure_to_index( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> usize

Returns an index, given an ending measure sum.

Runs in O(log N) time.

§Panics

Panics if the measure is out of bounds (i.e. measure > Rope::measure()).

Source

pub fn from_index(&self, index: usize) -> (M::Measure, M)

Returns the M at index and the starting measure sum of that element.

Runs in O(log N) time.

§Panics

Panics if the index is out of bounds (i.e. index > Rope::len()).

Source

pub fn from_measure( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> (M::Measure, M)

Returns the M at measure and the starting measure sum of that element.

Runs in O(log N) time.

§Panics

Panics if the measure is out of bounds (i.e. measure > Rope::measure()).

Source

pub fn chunk_at_index(&self, index: usize) -> (&[M], usize, M::Measure)

Returns the chunk containing the given index.

Also returns the index and widht of the beginning of the chunk.

Note: for convenience, a one-past-the-end index returns the last chunk of the RopeSlice.

The return value is organized as (chunk, chunk_index, chunk_measure).

Runs in O(log N) time.

§Panics

Panics if the index is out of bounds (i.e. index > Rope::len()).

Source

pub fn chunk_at_measure( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> (&[M], usize, M::Measure)

Returns the chunk containing the given measure.

Also returns the index and measure of the beginning of the chunk.

Note: for convenience, a one-past-the-end measure returns the last chunk of the RopeSlice.

The return value is organized as (chunk, chunk_index, chunk_measure).

Runs in O(log N) time.

§Panics

Panics if the measure is out of bounds (i.e. measure > Rope::measure()).

Source

pub fn measure_slice( &self, measure_range: impl MeasureRange<M>, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> RopeSlice<'_, M>

Gets an immutable slice of the Rope<M>, using a measure range.

Uses range syntax, e.g. 2..7, 2.., etc.

§Example
let mut rope = Rope::from_slice(&[
    Width(1),
    Width(2),
    Width(3),
    Width(0),
    Width(0),
    Width(2),
    Width(1),
]);
let slice = rope.measure_slice(..5, usize::cmp);

assert_eq!(slice, [Width(1), Width(2), Width(3)].as_slice());

Runs in O(log N) time.

§Panics

Panics if the start of the range is greater than the end, or if the end is out of bounds (i.e. end > Rope::measure()).

Source

pub fn index_slice( &self, index_range: impl RangeBounds<usize>, ) -> RopeSlice<'_, M>

Gets and immutable slice of the Rope<M>, using an index range.

Uses range syntax, e.g. 2..7, 2.., etc.

Runs in O(log N) time.

§Panics

Panics if:

  • The start of the range is greater than the end.
  • The end is out of bounds (i.e. end > Rope::len()).
Source

pub fn iter(&self) -> Iter<'_, M>

Creates an iterator over the Rope<M>.

This iterator will return values of type [Option<(usize, M)>], where the usize is the measure sum where the given M starts.

Runs in O(log N) time.

Source

pub fn iter_at_measure( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Iter<'_, M>

Creates an iterator over the Rope<M>, starting at measure.

This iterator will return values of type Option<(usize, M)>, where the usize is the measure where the given M starts. Since one can iterate in between an Ms start and end measure sums. the first usize may not actually corelate to the measure given to the function.

If measure == Rope::measure() then an iterator at the end of the Rope<M> is created (i.e. next() will return None).

Runs in O(log N) time.

§Panics

Panics if the measure is out of bounds (i.e. measure > Rope::measure()).

Source

pub fn chunks(&self) -> Chunks<'_, M>

Creates an iterator over the chunks of the Rope<M>.

Runs in O(log N) time.

Source

pub fn chunks_at_index( &self, index: usize, ) -> (Chunks<'_, M>, usize, M::Measure)

Creates an iterator over the chunks of the Rope<M>, with the iterator starting at the chunk containing the index.

Also returns the index and measure of the beginning of the first chunk to be yielded.

If index == Rope::len() an iterator at the end of the Rope<M> (yielding None on a call to next()) is created.

The return value is organized as (iterator, chunk_index, chunk_measure).

Runs in O(log N) time.

§Panics

Panics if the index is out of bounds (i.e. index > Rope::len()).

Source

pub fn chunks_at_measure( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> (Chunks<'_, M>, usize, M::Measure)

Creates an iterator over the chunks of the Rope<M>, with the iterator starting at the chunk containing the measure.

Also returns the index and measure of the beginning of the first chunk to be yielded.

If measure == Rope::measure() an iterator at the end of the Rope<M> (yielding None on a call to next()) is created.

The return value is organized as (iterator, chunk_index, chunk_measure).

Runs in O(log N) time.

§Panics

Panics if the measure is out of bounds (i.e. measure > Rope::measure()).

Source

pub fn is_instance(&self, other: &Self) -> bool

Returns true if this rope and other point to precisely the same in-memory data.

This happens when one of the ropes is a clone of the other and neither have been modified since then. Because clones initially share all the same data, it can be useful to check if they still point to precisely the same memory as a way of determining whether they are both still unmodified.

Note: this is distinct from checking for equality: two ropes can have the same contents (equal) but be stored in different memory locations (not instances). Importantly, two clones that post-cloning are modified identically will not be instances anymore, even though they will have equal contents.

Runs in O(1) time.

Source§

impl<M> Rope<M>
where M: Measurable, [(); { _ }]: Sized,

§Non-Panicking

The methods in this impl block provide non-panicking versions of Rope<M>’s panicking methods. They return either Option::None or Result::Err() when their panicking counterparts would have panicked.

Source

pub fn try_insert_slice( &mut self, measure: M::Measure, slice: &[M], cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Result<(), M>

Non-panicking version of insert().

Source

pub fn try_insert( &mut self, measure: M::Measure, measurable: M, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Result<(), M>

Non-panicking version of insert().

Source

pub fn try_remove_inclusive( &mut self, range: impl MeasureRange<M>, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Result<(), M>

Non-panicking version of remove_inclusive().

Source

pub fn try_remove_exclusive( &mut self, range: impl MeasureRange<M>, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Result<(), M>

Non-panicking version of remove_exclusive().

Source

pub fn try_split_off( &mut self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Result<Self, M>

Non-panicking version of split_off().

Source

pub fn try_index_to_measure(&self, index: usize) -> Result<M::Measure, M>

Non-panicking version of index_to_measure().

Source

pub fn try_start_measure_to_index( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Result<usize, M>

Non-panicking version of start_measure_to_index().

Source

pub fn try_end_measure_to_index( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Result<usize, M>

Non-panicking version of end_measure_to_index().

Source

pub fn get_from_index(&self, index: usize) -> Option<(M::Measure, M)>

Non-panicking version of from_index().

Source

pub fn get_from_measure( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Option<(M::Measure, M)>

Non-panicking version of from_measure().

Source

pub fn get_chunk_at_index( &self, index: usize, ) -> Option<(&[M], usize, M::Measure)>

Non-panicking version of chunk_at_index().

Source

pub fn get_chunk_at_measure( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Option<(&[M], usize, M::Measure)>

Non-panicking version of chunk_at_measure().

Source

pub fn get_measure_slice( &self, range: impl MeasureRange<M>, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Result<RopeSlice<'_, M>, M>

Non-panicking version of measure_slice().

Source

pub fn get_index_slice( &self, index_range: impl RangeBounds<usize>, ) -> Option<RopeSlice<'_, M>>

Non-panicking version of index_slice().

Source

pub fn get_iter_at_measure( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Option<Iter<'_, M>>

Non-panicking version of iter_at_measure().

Source

pub fn get_chunks_at_index( &self, index: usize, ) -> Option<(Chunks<'_, M>, usize, M::Measure)>

Non-panicking version of chunks_at_index().

Source

pub fn get_chunks_at_measure( &self, measure: M::Measure, cmp: impl Fn(&M::Measure, &M::Measure) -> Ordering, ) -> Option<(Chunks<'_, M>, usize, M::Measure)>

Non-panicking version of chunks_at_measure().

Trait Implementations§

Source§

impl<M> Clone for Rope<M>
where M: Measurable + Clone, [(); { _ }]: Sized,

Source§

fn clone(&self) -> Rope<M>

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<M> Debug for Rope<M>
where M: Measurable + Debug, [(); { _ }]: Sized,

Source§

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

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

impl<M> Default for Rope<M>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn default() -> Self

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

impl<M> Display for Rope<M>
where M: Measurable + Display, [(); { _ }]: Sized,

Source§

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

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

impl<'a, M> From<&'a [M]> for Rope<M>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn from(slice: &'a [M]) -> Self

Converts to this type from the input type.
Source§

impl<'a, M> From<&'a Rope<M>> for Cow<'a, [M]>
where M: Measurable, [(); { _ }]: Sized,

Attempts to borrow the contents of the Rope<M>, but will convert to an owned [M] if the contents is not contiguous in memory.

Runs in best case O(1), worst case O(N).

Source§

fn from(r: &'a Rope<M>) -> Self

Converts to this type from the input type.
Source§

impl<'a, M> From<&'a Rope<M>> for Vec<M>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn from(r: &'a Rope<M>) -> Self

Converts to this type from the input type.
Source§

impl<'a, M> From<Cow<'a, [M]>> for Rope<M>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn from(slice: Cow<'a, [M]>) -> Self

Converts to this type from the input type.
Source§

impl<'a, M> From<Rope<M>> for Cow<'a, [M]>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn from(r: Rope<M>) -> Self

Converts to this type from the input type.
Source§

impl<M> From<Rope<M>> for Vec<M>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn from(r: Rope<M>) -> Self

Converts to this type from the input type.
Source§

impl<'a, M> From<RopeSlice<'a, M>> for Rope<M>
where M: Measurable, [(); { _ }]: Sized,

Will share data where possible.

Runs in O(log N) time.

Source§

fn from(s: RopeSlice<'a, M>) -> Self

Converts to this type from the input type.
Source§

impl<M> From<Vec<M>> for Rope<M>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn from(slice: Vec<M>) -> Self

Converts to this type from the input type.
Source§

impl<'a, M> FromIterator<&'a [M]> for Rope<M>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = &'a [M]>,

Creates a value from an iterator. Read more
Source§

impl<'a, M> FromIterator<Cow<'a, [M]>> for Rope<M>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = Cow<'a, [M]>>,

Creates a value from an iterator. Read more
Source§

impl<M> FromIterator<Vec<M>> for Rope<M>
where M: Measurable, [(); { _ }]: Sized,

Source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = Vec<M>>,

Creates a value from an iterator. Read more
Source§

impl<M> Ord for Rope<M>
where M: Measurable + Ord, [(); { _ }]: Sized,

Source§

fn cmp(&self, other: &Rope<M>) -> 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<'a, M> PartialEq<&'a [M]> for Rope<M>
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &&'a [M]) -> 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<M> PartialEq<[M]> for Rope<M>
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &[M]) -> 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<'a, M> PartialEq<Cow<'a, [M]>> for Rope<M>
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &Cow<'a, [M]>) -> 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<'a, M> PartialEq<Rope<M>> for &'a [M]
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &Rope<M>) -> 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<M> PartialEq<Rope<M>> for [M]
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &Rope<M>) -> 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<'a, M> PartialEq<Rope<M>> for Cow<'a, [M]>
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &Rope<M>) -> 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<'a, M> PartialEq<Rope<M>> for RopeSlice<'a, M>
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &Rope<M>) -> 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<M> PartialEq<Rope<M>> for Vec<M>
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &Rope<M>) -> 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<'a, M> PartialEq<RopeSlice<'a, M>> for Rope<M>
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &RopeSlice<'a, M>) -> 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<M> PartialEq<Vec<M>> for Rope<M>
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &Vec<M>) -> 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<M> PartialEq for Rope<M>
where M: Measurable + PartialEq, [(); { _ }]: Sized,

Source§

fn eq(&self, other: &Rope<M>) -> 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<M> PartialOrd for Rope<M>
where M: Measurable + PartialOrd + Ord, [(); { _ }]: Sized,

Source§

fn partial_cmp(&self, other: &Rope<M>) -> 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<M> Eq for Rope<M>
where M: Measurable + Eq, [(); { _ }]: Sized,

Auto Trait Implementations§

§

impl<M> Freeze for Rope<M>
where [(); { _ }]: Sized,

§

impl<M> RefUnwindSafe for Rope<M>

§

impl<M> Send for Rope<M>
where [(); { _ }]: Sized, M: Send + Sync, <M as Measurable>::Measure: Sync + Send,

§

impl<M> Sync for Rope<M>
where [(); { _ }]: Sized, M: Send + Sync, <M as Measurable>::Measure: Sync + Send,

§

impl<M> Unpin for Rope<M>
where [(); { _ }]: Sized,

§

impl<M> UnwindSafe for Rope<M>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.