Point

Struct Point 

Source
pub struct Point { /* private fields */ }
Expand description

A position in Text

Implementations§

Source§

impl Point

Source

pub const fn new() -> Self

Returns a new Point, at the first byte

Source

pub const fn from_raw(b: usize, c: usize, l: usize) -> Self

A Point from raw indices

Source

pub const fn to_two_points_before(self) -> TwoPoints

Returns a new TwoPoints that includes the Ghosts in the same byte, if there is one

Source

pub const fn to_two_points_after(self) -> TwoPoints

Returns a new TwoPoints that skips the Ghosts in the same byte, if there is one

Source

pub fn len_of(str: impl AsRef<str>) -> Self

The len Point of a &str

This is the equivalent of Text::len, but for types other than Text

Source

pub const fn byte(&self) -> usize

Returns the byte (relative to the beginning of the buffer) of self. Indexed at 0

You can use byte indices to index the Text or Bytes with the Bytes::point_at_byte function.

Source

pub const fn char(&self) -> usize

Returns the char index (relative to the beginning of the buffer). Indexed at 0

This is the primary value used when indexing the Text and Bytes. That is, the Bytes::point_at_byte, Bytes::strs, and most other Bytes functions rely on a character indices (or Points) for indexing a Text.

Source

pub const fn line(&self) -> usize

Returns the line. Indexed at 0

You can use byte indices to index the Text or Bytes with the Bytes::point_at_line function.

Source

pub fn checked_sub(self, rhs: Point) -> Option<Point>

Checked Point subtraction

Trait Implementations§

Source§

impl Add for Point

Source§

type Output = Point

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for Point

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<'__de, __Context> BorrowDecode<'__de, __Context> for Point

Source§

fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>

Attempt to decode this type with the given BorrowDecode.
Source§

impl Clone for Point

Source§

fn clone(&self) -> Point

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Point

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<__Context> Decode<__Context> for Point

Source§

fn decode<__D: Decoder<Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>

Attempt to decode this type with the given Decode.
Source§

impl Default for Point

Source§

fn default() -> Point

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

impl Display for Point

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Encode for Point

Source§

fn encode<__E: Encoder>(&self, encoder: &mut __E) -> Result<(), EncodeError>

Encode a given type.
Source§

impl Hash for Point

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Point

Source§

fn cmp(&self, other: &Point) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Point

Source§

fn eq(&self, other: &Point) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Point

Source§

fn partial_cmp(&self, other: &Point) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub for Point

Source§

type Output = Point

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign for Point

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Tag<Point> for ExtraCaret

Source§

const IS_META: bool = false

A meta Tag is one that changes the layout of the Text itself Read more
Source§

impl Tag<Point> for MainCaret

Source§

const IS_META: bool = false

A meta Tag is one that changes the layout of the Text itself Read more
Source§

impl Tag<Point> for Spacer

Source§

const IS_META: bool = false

A meta Tag is one that changes the layout of the Text itself Read more
Source§

impl Tag<Point, GhostId> for Ghost

Source§

const IS_META: bool = true

A meta Tag is one that changes the layout of the Text itself Read more
Source§

impl Tag<Point, SpawnId> for SpawnTag

Source§

const IS_META: bool = false

A meta Tag is one that changes the layout of the Text itself Read more
Source§

impl TextIndex for Point

Source§

fn to_byte_index(self) -> usize

Converts this type into a byte index.
Source§

impl TextRangeOrIndex for Point

Source§

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

Transforms self into a Range<usize>
Source§

impl CaretOrRange for Point

Source§

impl Copy for Point

Source§

impl Eq for Point

Source§

impl StructuralPartialEq for Point

Auto Trait Implementations§

§

impl Freeze for Point

§

impl RefUnwindSafe for Point

§

impl Send for Point

§

impl Sync for Point

§

impl Unpin for Point

§

impl UnwindSafe for Point

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<D> AsBuilderPart<D, D> for D
where D: Display,

Source§

fn as_builder_part(&self) -> BuilderPart<'_, D, D>

Gets a BuilderPart fro this value
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<M> Measure for M
where M: Debug + PartialOrd + Add<Output = M> + Default + Clone,