Struct LxStr

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

A borrowed reference to a string that may or may not be valid utf-8.

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

Implementations§

Source§

impl LxStr

Source

pub fn new<T: AsRef<LxStr> + ?Sized>(s: &T) -> &LxStr

Coerces into an LxStr slice.

Source

pub fn from_bytes(slice: &[u8]) -> &LxStr

Creates an LxStr from a byte slice.

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 LxStr

Source§

fn as_ref(&self) -> &LxStr

Converts this type into a shared reference of the (usually inferred) input type.
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 AsRef<LxStr> for String

Source§

fn as_ref(&self) -> &LxStr

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

impl AsRef<LxStr> for str

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 Debug for LxStr

Source§

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

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

impl Hash for LxStr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
Source§

impl PartialEq<LxStr> for str

Source§

fn eq(&self, other: &LxStr) -> 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 LxStr

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 LxStr

Source§

fn eq(&self, other: &LxStr) -> 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 ToOwned for LxStr

Source§

type Owned = LxString

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl Eq for LxStr

Source§

impl StructuralPartialEq for LxStr

Auto Trait Implementations§

§

impl Freeze for LxStr

§

impl RefUnwindSafe for LxStr

§

impl Send for LxStr

§

impl !Sized for LxStr

§

impl Sync for LxStr

§

impl Unpin for LxStr

§

impl UnwindSafe for LxStr

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