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
impl Ranges
Sourcepub fn set_min_len(&mut self, min: usize)
pub fn set_min_len(&mut self, min: usize)
Sets a minimum length to keep Ranges
Sourcepub fn add(&mut self, new: Range<usize>) -> bool
pub fn add(&mut self, new: Range<usize>) -> bool
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.
This function will return true if the Ranges were changed
by this addition.
Sourcepub fn extend(&mut self, ranges: impl IntoIterator<Item = Range<usize>>) -> bool
pub fn extend(&mut self, ranges: impl IntoIterator<Item = Range<usize>>) -> bool
Adds many Ranges to be merged with the existing ones
This function will return true if the Ranges were changed
by this addition.
Sourcepub fn remove_intersecting(
&mut self,
within: Range<usize>,
) -> impl Iterator<Item = Range<usize>>
pub fn remove_intersecting( &mut self, within: Range<usize>, ) -> impl Iterator<Item = Range<usize>>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of Range<usize>s
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there are no Range<usize>s
Sourcepub fn iter_over(
&self,
within: Range<usize>,
) -> impl Iterator<Item = Range<usize>>
pub fn iter_over( &self, within: Range<usize>, ) -> impl Iterator<Item = Range<usize>>
The same as Ranges::remove_on, but without removing, just
iterating over the relevant ranges
This method will trim the iterated Ranges to the bounds of
within. If you want a non trimmed version of this method,
check out iter_intersecting.
Sourcepub fn iter_intersecting(
&self,
within: Range<usize>,
) -> impl Iterator<Item = Range<usize>>
pub fn iter_intersecting( &self, within: Range<usize>, ) -> impl Iterator<Item = Range<usize>>
Iterates over all Ranges that intersect with within
If you want to automatically trim those ranges to the bounds
of within, check out iter_over. If you want to remove
the ranges that intersect with the given one, see,
Ranges::remove_intersecting