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

Points to a certain character.

A TextPosition also keeps track of the human-interpretable position (ie. line/column).

Implementations

Crate a new TextPosition from raw parts

The absolute index pointing to the char. 0 is the first character.

The line this position is on. 1 is the first line.

This is always equals to the number of inc_line() calls made on this position.

The column this position is on. 1 is the first column.

This is always equals to the number of inc_col() calls made on this position after the last inc_line() call.

Move the position forward by one non-newline character.

Move the position forward by one newline character.

Return the previous position.

Note, that when this is used on a position that is on the first column, then this will yield a previous position at the zeroth column (which doesn’t exist, 1 is the first column). Conceptually this represents the last character of the previous line, ie. the newline character.

Also, this function may not be called on a zeroth-column position or on a character with index 0.

Due to these peculiarities, the returned position should not be reused for further computations, only for formatting purposes.

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 returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. 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

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. 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.