Trait TextRange

Source
pub trait TextRange: Clone {
    // Required methods
    fn to_range_fwd(self, max: usize) -> Range<usize>;
    fn to_range_rev(self, max: usize) -> Range<usize>;
    fn to_range_at(self, max: usize) -> Range<usize>;
}
Expand description

Ranges that can be used to index the Text

These include:

The behavior of usize and Point depends on where they are sent, but is pretty straightforward:

  • On forward iterators, they act as a RangeFrom
  • On reverse iterators, they act as a RangeTo
  • On insertion of Tags, they act as a 1 element range

The purpose of this trait is to minimize the number of functions needed to perform tasks.

Required Methods§

Source

fn to_range_fwd(self, max: usize) -> Range<usize>

A “forward facing range”

If given a single usize/Point, acts like RangeFrom

Source

fn to_range_rev(self, max: usize) -> Range<usize>

A “reverse facing range”

If given a single usize/Point, acts like RangeTo

Source

fn to_range_at(self, max: usize) -> Range<usize>

A “single point range”

If given a single usize/Point, acts like one element

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TextRange for (Option<Point>, Option<Point>)

Source§

impl TextRange for (Option<Point>, Point)

Source§

impl TextRange for (Point, Option<Point>)

Source§

impl TextRange for (Point, Point)

Source§

impl TextRange for usize

Source§

impl TextRange for Range<usize>

Source§

impl TextRange for RangeFrom<usize>

Source§

impl TextRange for RangeFull

Source§

impl TextRange for RangeInclusive<usize>

Source§

impl TextRange for RangeTo<usize>

Source§

impl TextRange for RangeToInclusive<usize>

Implementors§