RuneParts

Struct RuneParts 

Source
pub struct RuneParts {
    pub ptr: *const u8,
    pub length: usize,
}
Expand description

Represents a memory area with contiguous bytes that serves as building block for Runes and Rune.

Β§Examples

 use utf8_rune::{RuneParts, Rune, Runes};
 let parts = RuneParts::new("πŸ‘ŒπŸ‘ŒπŸ»πŸ‘ŒπŸΌπŸ‘ŒπŸ½πŸ‘ŒπŸΎπŸ‘ŒπŸΏ");
 assert_eq!(parts.len(), 44);
 assert_eq!(parts.as_str(), "πŸ‘ŒπŸ‘ŒπŸ»πŸ‘ŒπŸΌπŸ‘ŒπŸ½πŸ‘ŒπŸΎπŸ‘ŒπŸΏ");
 assert_eq!(parts.as_bytes(), "πŸ‘ŒπŸ‘ŒπŸ»πŸ‘ŒπŸΌπŸ‘ŒπŸ½πŸ‘ŒπŸΎπŸ‘ŒπŸΏ".as_bytes());

 let runes = parts.into_runes();
 assert_eq!(runes.len(), 6);
 assert_eq!(runes[0], "πŸ‘Œ");
 assert_eq!(runes[1], "πŸ‘ŒπŸ»");
 assert_eq!(runes[2], "πŸ‘ŒπŸΌ");
 assert_eq!(runes[3], "πŸ‘ŒπŸ½");
 assert_eq!(runes[4], "πŸ‘ŒπŸΎ");
 assert_eq!(runes[5], "πŸ‘ŒπŸΏ");

FieldsΒ§

Β§ptr: *const u8Β§length: usize

ImplementationsΒ§

SourceΒ§

impl RuneParts

Source

pub fn from_raw_parts(ptr: *const u8, length: usize) -> RuneParts

Source

pub fn new<T: Display>(input: T) -> RuneParts

Source

pub fn into_runes<'g>(self) -> Runes<'g>

Source

pub fn allocate<T: Display>(input: T) -> Result<RuneParts>

Source

pub fn rune(&self) -> Option<Rune>

Source

pub fn indexes(&self) -> Vec<usize>

Source

pub fn rune_at_index(&self, index: usize) -> Result<Rune>

Source

pub fn runes(&self) -> Result<Vec<Rune>>

Source

pub fn len(&self) -> usize

Source

pub fn as_str<'g>(&self) -> &'g str

Source

pub fn as_bytes<'g>(&self) -> &'g [u8] β“˜

Source

pub fn is_empty(&self) -> bool

Source

pub fn as_debug(&self, indent: Option<usize>) -> String

Trait ImplementationsΒ§

SourceΒ§

impl Clone for RuneParts

SourceΒ§

fn clone(&self) -> RuneParts

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 RuneParts

SourceΒ§

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

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

impl Display for RuneParts

SourceΒ§

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

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

impl From<&String> for RuneParts

SourceΒ§

fn from(s: &String) -> RuneParts

Converts to this type from the input type.
SourceΒ§

impl From<&str> for RuneParts

SourceΒ§

fn from(s: &str) -> RuneParts

Converts to this type from the input type.
SourceΒ§

impl From<String> for RuneParts

SourceΒ§

fn from(s: String) -> RuneParts

Converts to this type from the input type.
SourceΒ§

impl Copy for RuneParts

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> 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<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.