Struct xcb::Lat1String

source ·
pub struct Lat1String { /* private fields */ }
Expand description

A struct owning a Latin-1 (aka. ISO 8859-1) string.

See Lat1Str for details.

Implementations§

source§

impl Lat1String

source

pub fn from_bytes(bytes: &[u8]) -> Self

Construct a Lat1String from a slice of bytes.

source

pub fn from_utf8(str: &str) -> Self

Construct a Lat1String from UTF-8 (a conversion to Latin-1 is performed).

Methods from Deref<Target = Lat1Str>§

source

pub fn is_ascii(&self) -> bool

Checks whether the slice only contains ASCII characters.

source

pub fn len(&self) -> usize

Returns the number of characters in the string.

source

pub fn as_bytes(&self) -> &[u8]

Returns the string as slice of bytes.

source

pub fn try_as_ascii(&self) -> Result<&str, Lat1Error>

Returns the string in UTF-8 encoding, only if the string is pure ASCII. Otherwise, a Lat1Error::NonAscii is returned.

source

pub fn as_ascii(&self) -> &str

Returns the string in UTF-8 encoding, only if the string is pure ASCII.

§Panics

This function panics if the string contains non-ASCII chars.

source

pub unsafe fn as_ascii_unchecked(&self) -> &str

Returns the string in UTF-8 encoding.

§Safety

If the string contains non-ASCII characters, the returned string will be invalid UTF-8.

source

pub fn to_utf8(&self) -> Cow<'_, str>

Returns the string converted to UTF-8.

Cow::Borrowed is returned if the string is pure ASCII, otherwise a conversion to UTF-8 is performed and Cow::Owned is returned.

Trait Implementations§

source§

impl Borrow<Lat1Str> for Lat1String

source§

fn borrow(&self) -> &Lat1Str

Immutably borrows from an owned value. Read more
source§

impl Clone for Lat1String

source§

fn clone(&self) -> Lat1String

Returns a copy 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 Lat1String

source§

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

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

impl Deref for Lat1String

§

type Target = Lat1Str

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl Display for Lat1String

source§

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

Formats the value using the given formatter. Read more

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<T> ToOwned for T
where T: Clone,

§

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§

default 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>,

§

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

§

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.