Ranges

Struct Ranges 

Source
pub struct Ranges { /* private fields */ }
Expand description

A list of non intersecting exclusive Range<usize>s

The primary purpose of this struct is to serve Parsers by telling Duat which ranges need to be updated. This lets Duat minimize as much as possible the amount of work done to update the Text when it changes in a Buffer.

Implementations§

Source§

impl Ranges

Source

pub fn new(range: Range<usize>) -> Self

Return a new instance of Ranges with an initial Range

Source

pub fn empty() -> Self

Returns a new empty Ranges

Source

pub fn set_min_len(&mut self, min: usize)

Sets a minimum length to keep Ranges

Source

pub fn add(&mut self, new: Range<usize>)

Adds a range to the list of Range<usize>s

This range will be merged in with the others on the list, so it may bridge gaps between ranges or for longer ranges within, without allowing for the existance of intersecting ranges.

Source

pub fn remove( &mut self, within: Range<usize>, ) -> impl ExactSizeIterator<Item = Range<usize>> + '_

Removes a Range from the list, returning an Iterator over the Ranges that were taken

Source

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

Applies the add function to another Rangess

Source

pub fn shift_by(&mut self, from: usize, shift: i32)

Shifts the Ranges within by a Change

If the diff is negative (i.e. a part of the ranges were removed), then ranges will be removed ahead of from accordingly.

Source

pub fn len(&self) -> usize

Returns the number of Range<usize>s

Source

pub fn is_empty(&self) -> bool

Returns true if there are no Range<usize>s

Source

pub fn iter(&self) -> impl Iterator<Item = Range<usize>>

An Iterator over the Ranges in this list

Source

pub fn iter_over( &self, within: Range<usize>, ) -> impl Iterator<Item = Range<usize>>

The same as Ranges::remove, but without removing, just iterating over the relevant ranges

Trait Implementations§

Source§

impl Clone for Ranges

Source§

fn clone(&self) -> Ranges

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 Debug for Ranges

Source§

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

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

impl Default for Ranges

Source§

fn default() -> Ranges

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

impl IntoIterator for Ranges

Source§

type IntoIter = IntoIter

Which kind of iterator are we turning this into?
Source§

type Item = Range<usize>

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl Freeze for Ranges

§

impl RefUnwindSafe for Ranges

§

impl Send for Ranges

§

impl Sync for Ranges

§

impl Unpin for Ranges

§

impl UnwindSafe for Ranges

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> 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<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<I> IntoIteratorExt<I> for I
where I: IntoIterator,

Source§

fn into_into_lender(self) -> FromIntoIter<I>

Turn this IntoIterator into a IntoLender without allocation. Read more
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.