Struct ra_ap_text_edit::TextSize [−][src]
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
impl TextSize
[src]
impl TextSize
[src]pub fn of<T>(text: T) -> TextSize where
T: TextLen,
[src]
pub fn of<T>(text: T) -> TextSize where
T: TextLen,
[src]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));
impl TextSize
[src]
impl TextSize
[src]Methods to act like a primitive integer type, where reasonably applicable.
pub fn checked_add(self, rhs: TextSize) -> Option<TextSize>
[src]
pub fn checked_add(self, rhs: TextSize) -> Option<TextSize>
[src]Checked addition. Returns None
if overflow occurred.
pub fn checked_sub(self, rhs: TextSize) -> Option<TextSize>
[src]
pub fn checked_sub(self, rhs: TextSize) -> Option<TextSize>
[src]Checked subtraction. Returns None
if overflow occurred.
Trait Implementations
impl<'_, T> Add<T> for &'_ TextSize where
TextSize: Add<T>,
<TextSize as Add<T>>::Output == TextSize,
[src]
impl<'_, T> Add<T> for &'_ TextSize where
TextSize: Add<T>,
<TextSize as Add<T>>::Output == TextSize,
[src]impl<A> AddAssign<A> for TextSize where
TextSize: Add<A>,
<TextSize as Add<A>>::Output == TextSize,
[src]
impl<A> AddAssign<A> for TextSize where
TextSize: Add<A>,
<TextSize as Add<A>>::Output == TextSize,
[src]pub fn add_assign(&mut self, rhs: A)
[src]
pub fn add_assign(&mut self, rhs: A)
[src]Performs the +=
operation. Read more
impl Ord for TextSize
[src]
impl Ord for TextSize
[src]impl PartialOrd<TextSize> for TextSize
[src]
impl PartialOrd<TextSize> for TextSize
[src]pub fn partial_cmp(&self, other: &TextSize) -> Option<Ordering>
[src]
pub fn partial_cmp(&self, other: &TextSize) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl RangeBounds<TextSize> for TextRange
[src]
impl RangeBounds<TextSize> for TextRange
[src]pub fn start_bound(&self) -> Bound<&TextSize>
[src]
pub fn start_bound(&self) -> Bound<&TextSize>
[src]Start index bound. Read more
fn contains<U>(&self, item: &U) -> bool where
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,
1.35.0[src]
fn contains<U>(&self, item: &U) -> bool where
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,
1.35.0[src]Returns true
if item
is contained in the range. Read more
impl<'_, T> Sub<T> for &'_ TextSize where
TextSize: Sub<T>,
<TextSize as Sub<T>>::Output == TextSize,
[src]
impl<'_, T> Sub<T> for &'_ TextSize where
TextSize: Sub<T>,
<TextSize as Sub<T>>::Output == TextSize,
[src]impl<S> SubAssign<S> for TextSize where
TextSize: Sub<S>,
<TextSize as Sub<S>>::Output == TextSize,
[src]
impl<S> SubAssign<S> for TextSize where
TextSize: Sub<S>,
<TextSize as Sub<S>>::Output == TextSize,
[src]pub fn sub_assign(&mut self, rhs: S)
[src]
pub fn sub_assign(&mut self, rhs: S)
[src]Performs the -=
operation. Read more
impl TryFrom<usize> for TextSize
[src]
impl TryFrom<usize> for TextSize
[src]type Error = TryFromIntError
type Error = TryFromIntError
The type returned in the event of a conversion error.
impl Copy for TextSize
[src]
impl Eq for TextSize
[src]
impl StructuralEq for TextSize
[src]
impl StructuralPartialEq for TextSize
[src]
Auto Trait Implementations
impl RefUnwindSafe for TextSize
impl Send for TextSize
impl Sync for TextSize
impl Unpin for TextSize
impl UnwindSafe for TextSize
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more