Trait Ext

Source
pub trait Ext {
    const MAX: Self;
    const MIN: Self;

    // Required methods
    fn offset(&mut self, lines: i32, characters: i32);
    fn set_line(&mut self, line: u32);
    fn set_character(&mut self, character: u32);
    fn is_in_bounds(&self, start: Self, end: Self) -> bool;
    fn is_after(&self, position: Self) -> bool;
    fn is_before(&self, position: Self) -> bool;
}
Expand description

Extands the Position type by adding helper functions.

Required Associated Constants§

Source

const MAX: Self

The largest value that can be represented by a Position.

Source

const MIN: Self

The smallest value that can be represented by a Position.

Required Methods§

Source

fn offset(&mut self, lines: i32, characters: i32)

Offsets the current position by lines and characters. If you’re adding both lines and characters, making sure to set characters to 0 before calling this function to ensure correct results.

Source

fn set_line(&mut self, line: u32)

Sets line to a specific value.

Source

fn set_character(&mut self, character: u32)

Sets character to a specific value.

Source

fn is_in_bounds(&self, start: Self, end: Self) -> bool

Checks whether or not this position is between the 2 passed positions.

Source

fn is_after(&self, position: Self) -> bool

Checks whether or not this position is after the passed position.

Source

fn is_before(&self, position: Self) -> bool

Checks whether or not this position is before the passed position.

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.

Implementors§