Struct rslint_parser::TextSize[]

pub struct TextSize { /* fields omitted */ }
Expand description

A measure of text length. Also, equivalently, an index into text.

This is a UTF-8 bytes offset stored as u32, but most clients should treat it as an opaque measure.

For cases that need to escape TextSize and return to working directly with primitive integers, TextSize can be converted losslessly to/from u32 via From conversions as well as losslessly be converted Into usize. The usize -> TextSize direction can be done via TryFrom.

These escape hatches are primarily required for unit testing and when converting from UTF-8 size to another coordinate space, such as UTF-16.

Implementations

The text size of some primitive text-like object.

Accepts char, &str, and &String.

Examples

let char_size = TextSize::of('🦀');
assert_eq!(char_size, TextSize::from(4));

let str_size = TextSize::of("rust-analyzer");
assert_eq!(str_size, TextSize::from(13));

Methods to act like a primitive integer type, where reasonably applicable.

Checked addition. Returns None if overflow occurred.

Checked subtraction. Returns None if overflow occurred.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

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

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. 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 !=.

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

Start index bound. Read more

End index bound. Read more

Returns true if item is contained in the range. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

Method which takes an iterator and generates Self from the elements by “summing up” the items. Read more

The type returned in the event of a conversion error.

Performs the conversion.

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

Unerase this erased pointer. Read more

Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more

Turn this erasable pointer into an erased pointer. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. 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.