Skip to main content

Utf16String

Struct Utf16String 

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

An owned UTF-16 string consisting of UCS-2 code units.

Indexing this type is equivalent to indexing UTF-16 code units (not bytes), which are represented by u16.

Implementations§

Source§

impl Utf16String

Source

pub fn new() -> Self

Source

pub fn as_mut_utf16_str(&mut self) -> &mut Utf16Str

Source

pub unsafe fn as_mut_vec(&mut self) -> &mut Vec<u16>

Source

pub fn clear(&mut self)

Source

pub fn insert(&mut self, index: usize, ch: char)

Source

pub fn insert_utf16_str(&mut self, index: usize, string: &Utf16Str)

Source

pub fn insert_utf8_str(&mut self, index: usize, string: &str)

Source

pub fn push(&mut self, ch: char)

Source

pub fn push_utf16_str(&mut self, string: &Utf16Str)

Source

pub fn push_utf8_str(&mut self, string: &str)

Source

pub fn remove(&mut self, index: usize) -> char

Removes a surrogate pair or a code unit from the specified index in code units, and returns the code point that was removed.

§Panics

Panics if the index is out of bounds.

Source

pub fn pop(&mut self) -> Option<char>

Removes the last surrogate pair or code unit, and returns the code point that was removed.

Methods from Deref<Target = Utf16Str>§

Source

pub fn len(&self) -> usize

Returns the number of UTF-16 code units representing the string.

Source

pub fn as_ptr(&self) -> *const u16

Source

pub fn as_mut_ptr(&mut self) -> *mut u16

Source

pub fn code_units(&self) -> Iter<'_, u16>

Iterates the UTF-16 code units.

Source

pub fn chars(&self) -> Utf16Chars<'_>

Iterates the code points in the string.

Source

pub fn char_indices(&self) -> Utf16CharIndices<'_>

Iterates the indices and their code pointss in the string.

Source

pub fn get<I: SliceIndex<Utf16Str>>( &self, index: I, ) -> Option<&<I as SliceIndex<Utf16Str>>::Output>

Source

pub fn get_mut<I: SliceIndex<Utf16Str>>( &mut self, index: I, ) -> Option<&mut <I as SliceIndex<Utf16Str>>::Output>

Source

pub unsafe fn get_unchecked<I: SliceIndex<Utf16Str>>( &self, index: I, ) -> &<I as SliceIndex<Utf16Str>>::Output

Source

pub unsafe fn get_unchecked_mut<I: SliceIndex<Utf16Str>>( &mut self, index: I, ) -> &mut <I as SliceIndex<Utf16Str>>::Output

Source

pub fn is_empty(&self) -> bool

Source

pub fn to_owned(&self) -> Utf16String

Source

pub fn to_utf8(&self) -> String

Source

pub fn to_lowercase(&self) -> Utf16String

Source

pub fn to_uppercase(&self) -> Utf16String

Trait Implementations§

Source§

impl Debug for Utf16String

Source§

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

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

impl Default for Utf16String

Source§

fn default() -> Self

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

impl Deref for Utf16String

Source§

type Target = Utf16Str

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Utf16String

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: AsRef<str>> From<T> for Utf16String

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl From<Utf16String> for String

Source§

fn from(value: Utf16String) -> Self

Converts to this type from the input type.
Source§

impl Hash for Utf16String

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<I> Index<I> for Utf16String
where I: SliceIndex<Utf16Str>,

Source§

type Output = <I as SliceIndex<Utf16Str>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &I::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<I> IndexMut<I> for Utf16String
where I: SliceIndex<Utf16Str>,

Source§

fn index_mut(&mut self, index: I) -> &mut I::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl PartialEq for Utf16String

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Eq for Utf16String

Source§

impl StructuralPartialEq for Utf16String

Auto Trait Implementations§

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<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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.