Struct LxString

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

An owned string that may or may not be valid utf-8.

This is analogous to OsString on Linux, but behaves the same on all platforms.

Implementations§

Source§

impl LxString

Source

pub fn new() -> Self

Creates an empty LxString.

Source

pub fn from_vec(vec: Vec<u8>) -> Self

Creates a LxString from a byte vector.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates a LxString with the specified capacity.

Source

pub fn into_vec(self) -> Vec<u8>

Yields the underlying byte vector of this LxString.

Source

pub fn into_string(self) -> Result<String, Self>

Converts the LxString into a String if it contains valid Unicode data.

Source

pub fn as_lx_str(&self) -> &LxStr

Converts to an LxStr slice.

Source

pub fn capacity(&self) -> usize

Returns the capacity of the LxString.

Source

pub fn clear(&mut self)

Clears the contents of the LxString.

Source

pub fn push(&mut self, s: &impl AsRef<LxStr>)

Extends the string with the given &OsStr slice.

Source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more capacity to be inserted in the given OsString.

Source

pub fn reserve_exact(&mut self, additional: usize)

Reserves the minimum capacity for exactly additional more capacity to be inserted in the given LxString. Does nothing if the capacity is already sufficient.

Source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of the LxString to match its length.

Methods from Deref<Target = LxStr>§

Source

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

Gets the underlying byte view of the LxStr slice.

Source

pub fn to_lx_string(&self) -> LxString

Copies the slice into an owned LxString.

Source

pub fn len(&self) -> usize

Returns the length of this LxStr.

Source

pub fn is_empty(&self) -> bool

Checks whether the LxStr is empty.

Source

pub fn to_str(&self) -> Option<&str>

Yields a &str slice if the LxStr is valid Unicode.

Source

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

Convert an LxStr to a Cow<str>.

Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.

Trait Implementations§

Source§

impl AsRef<LxStr> for LxString

Source§

fn as_ref(&self) -> &LxStr

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<LxStr> for LxString

Source§

fn borrow(&self) -> &LxStr

Immutably borrows from an owned value. Read more
Source§

impl Clone for LxString

Source§

fn clone(&self) -> LxString

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 LxString

Source§

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

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

impl Default for LxString

Source§

fn default() -> LxString

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

impl Deref for LxString

Source§

type Target = LxStr

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<T> From<&T> for LxString
where T: ?Sized + AsRef<LxStr>,

Source§

fn from(s: &T) -> Self

Converts to this type from the input type.
Source§

impl From<String> for LxString

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for LxString

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 PartialEq<&str> for LxString

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<LxString> for &str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<LxString> for str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<str> for LxString

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq for LxString

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 LxString

Source§

impl StructuralPartialEq for LxString

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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, 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.