pub struct TextRange { /* private fields */ }
Expand description

Defines a range in a text.

A range is defined by two TextPositions: base and next. base is the first character (ie. inclusive) and next is just outside of the range (ie. exclusive).

This graphic shows how they work:

          Range
       ___________
   L o r e m   i p s u m
       -           -
       |           |
       |           |
     base         next

(in this example, the range would be “rem ip”)

Note that due to this, the character at next may not actually exist.

Implementations

Create a new text range with base as the first character (inclusive) and next after the last character (exclusive).

They may point to the same location (in which case the range is empty), but next may not be smaller than base.

See also the documentation on TextPosition for the roles of base and next.

Create a new empty range at pos.

Append a non-newline character to the range.

Append a newline character to the range.

Merge other into self.

self must be immediately before other. This means there may not be any characters between self.last() and other.first(), but the latter must still be after the former.

Create a new empty range immediately after self.

Get the base character position

Get the next character position

The number of characters contained in the range

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.