FlexStr

Enum FlexStr 

Source
pub enum FlexStr<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> {
    Borrowed(&'s S),
    Inlined(InlineFlexStr<S>),
    RefCounted(R),
    Boxed(Box<S>),
}
Expand description

Flexible string type that can store a borrowed string, an inline string, a reference counted string, or a boxed string

Variants§

§

Borrowed(&'s S)

Borrowed string - borrowed strings are imported as &S

§

Inlined(InlineFlexStr<S>)

Inline string - owned strings that are small enough to be stored inline

§

RefCounted(R)

Reference counted string - owned strings that are too large for inline storage

§

Boxed(Box<S>)

Boxed string - heap allocated strings are imported as Box<S>

Implementations§

Source§

impl<'s, R: RefCounted<CStr>> FlexStr<'s, CStr, R>

Source

pub fn try_from_bytes_with_or_without_nul( bytes: &'s [u8], ) -> Result<Self, InteriorNulError>

Available on crate feature cstr only.

Attempt to create a CStr from borrowed bytes with or without a trailing NUL byte.

Source

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

Available on crate feature cstr only.

Borrow the CStr as bytes with a trailing NUL byte

Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> FlexStr<'s, S, R>
where for<'a> &'a S: Default,

Source

pub fn empty() -> FlexStr<'s, S, R>

Create a new empty string. This is a Borrowed variant.

Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> FlexStr<'s, S, R>
where Box<S>: From<S::Owned>,

Source

pub fn from_owned(s: S::Owned) -> FlexStr<'static, S, R>

Create a new string from an owned string (most likely without copy or allocation). The result is a Boxed variant.

Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> FlexStr<'s, S, R>

Source

pub const fn from_borrowed(s: &'s S) -> FlexStr<'s, S, R>

Create a new string from a borrowed string. This is a const fn because it does not allocate and results in a Borrowed variant.

Source

pub fn from_inline(s: InlineFlexStr<S>) -> FlexStr<'s, S, R>

Create a new string from an inline string. This results in an Inlined variant.

Source

pub fn from_ref_counted(s: R) -> FlexStr<'s, S, R>

Create a new string from a reference counted string. This results in a RefCounted variant.

Source

pub fn from_boxed(s: Box<S>) -> FlexStr<'s, S, R>

Create a new string from a boxed string. This results in a Boxed variant.

Source

pub fn is_borrowed(&self) -> bool

Returns true if this is a borrowed string

Source

pub fn is_inlined(&self) -> bool

Returns true if this is an inlined string

Source

pub fn is_ref_counted(&self) -> bool

Returns true if this is a reference counted string

Source

pub fn is_boxed(&self) -> bool

Returns true if this is a boxed string

Source

pub fn is_on_heap(&self) -> bool

Returns true if this is a string that is on the heap

Source

pub fn is_off_heap(&self) -> bool

Returns true if this is a string that is off the heap

Source

pub fn optimize(self) -> FlexStr<'s, S, R>

Optimize the string variant. This is a no-op for Inlined/Borrowed variants. RefCounted strings will attempt to inline, but otherwise be left as ref counted. Boxed strings will attempt to inline, but otherwise be converted to a ref counted string.

Source

pub fn to_owned(&self) -> FlexStr<'static, S, R>

Convert a string reference to an owned string. Inlined/RefCounted variants are cloned, Borrowed/Boxed variants are copied into a new Inlined or RefCounted owned string.

Source

pub fn into_owned(self) -> FlexStr<'static, S, R>

Consume a string and convert it to an owned string. Inlined/RefCounted/Boxed variants are moved, Borrowed variants are copied into a new Inlined or RefCounted owned string.

Source

pub fn as_ref_type(&self) -> &S

Borrow a string reference as &S

Source

pub fn to_owned_type(&self) -> S::Owned

Convert a string reference to an owned string. S::to_owned is called on all variants.

Source

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

Borrow the string as a raw byte slice (NOTE: includes trailing NUL for CStr)

Source

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

Borrow the string as bytes

Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> FlexStr<'s, S, R>
where S::Owned: From<Box<S>>,

Source

pub fn into_owned_type(self) -> S::Owned

Consume a string and convert it to an owned string. S::to_owned is called on Borrowed/Inlined/RefCounted variants. Boxed variants are converted directly into S::Owned (most likely without copy or allocation).

Source§

impl<'s, S: ?Sized + ImmutableBytes, R: RefCountedMut<S>> FlexStr<'s, S, R>

Source

pub fn to_mut_type_fallback(&mut self) -> &mut S

Borrow the string as a mutable string reference, converting if needed. If the string is Borrowed, it is made into a reference counted string first. RefCounted variants will allocate + copy if they are shared. In all other cases, the string is borrowed as a mutable reference directly.

Source§

impl<'s, S: ?Sized + StringFromBytesMut, R: RefCountedMut<S>> FlexStr<'s, S, R>

Source

pub fn to_mut_type(&mut self) -> &mut S

Borrow the string as a mutable string reference, converting if needed. If the string is borrowed, it is made into an owned string first. RefCounted variants will allocate + copy if they are shared. In all other cases, the string is borrowed as a mutable reference directly.

Source§

impl<'s, S: ?Sized + StringToFromBytes> FlexStr<'s, S, Arc<S>>
where Arc<S>: for<'a> From<&'a S>, Rc<S>: for<'a> From<&'a S>,

Source

pub fn to_local(&self) -> FlexStr<'s, S, Rc<S>>

Convert a shared string reference to a local string. The Borrowed/Inlined variants are copied, RefCounted is copied into a new allocation, and Boxed is copied into an Inlined or RefCounted variant.

Source

pub fn into_local(self) -> FlexStr<'s, S, Rc<S>>

Consume a shared string and convert it to a local string. The Borrowed/Inlined/Boxed variants are moved, and RefCounted is copied into a new allocation.

Source§

impl<'s, S: ?Sized + StringToFromBytes> FlexStr<'s, S, Rc<S>>
where Rc<S>: for<'a> From<&'a S>, Arc<S>: for<'a> From<&'a S>,

Source

pub fn to_shared(&self) -> FlexStr<'s, S, Arc<S>>

Convert a local string reference to a shared string. The Borrowed/Inlined variants are copied, RefCounted is copied into a new allocation, and Boxed is copied into an Inlined or RefCounted variant.

Source

pub fn into_shared(self) -> FlexStr<'s, S, Arc<S>>

Consume a local string and convert it to a shared string. The Borrowed/Inlined/Boxed variants are moved, and RefCounted is copied into a new allocation.

Trait Implementations§

Source§

impl<'s, S, R: RefCounted<S>> AsRef<[u8]> for FlexStr<'s, S, R>
where S: AsRef<[u8]> + ?Sized + StringToFromBytes,

Available on crate feature bytes only.
Source§

fn as_ref(&self) -> &[u8]

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

impl<'s, S, R: RefCounted<S>> AsRef<CStr> for FlexStr<'s, S, R>

Available on crate feature cstr only.
Source§

fn as_ref(&self) -> &CStr

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

impl<'s, S, R: RefCounted<S>> AsRef<OsStr> for FlexStr<'s, S, R>

Available on crate features std and osstr only.
Source§

fn as_ref(&self) -> &OsStr

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

impl<'s, S, R: RefCounted<S>> AsRef<Path> for FlexStr<'s, S, R>

Available on crate features std and path only.
Source§

fn as_ref(&self) -> &Path

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

impl<'s, S, R: RefCounted<S>> AsRef<str> for FlexStr<'s, S, R>

Available on crate feature str only.
Source§

fn as_ref(&self) -> &str

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

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> Borrow<S> for FlexStr<'s, S, R>

Source§

fn borrow(&self) -> &S

Immutably borrows from an owned value. Read more
Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> Clone for FlexStr<'s, S, R>

Source§

fn clone(&self) -> Self

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<'s, S: Debug + ?Sized + StringToFromBytes, R: Debug + RefCounted<S>> Debug for FlexStr<'s, S, R>

Source§

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

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

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> Default for FlexStr<'s, S, R>
where for<'a> &'a S: Default,

Source§

fn default() -> FlexStr<'s, S, R>

Create a new string from a default value

Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> Deref for FlexStr<'s, S, R>

Source§

type Target = S

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<'de, S: ?Sized + StringToFromBytes, R: RefCounted<S>> Deserialize<'de> for FlexStr<'static, S, R>
where Box<S>: Deserialize<'de>,

Available on crate feature serde only.
Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'s, S, R: RefCounted<S>> Display for FlexStr<'s, S, R>

Source§

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

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

impl<'s, R: RefCounted<Path>> From<&'s OsStr> for FlexStr<'s, Path, R>

Available on crate features std and path only.
Source§

fn from(s: &'s OsStr) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<OsStr>> From<&'s Path> for FlexStr<'s, OsStr, R>

Available on crate features std and osstr only.
Source§

fn from(p: &'s Path) -> Self

Converts to this type from the input type.
Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> From<&'s S> for FlexStr<'s, S, R>

Source§

fn from(s: &'s S) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<[u8]>> From<&'s str> for FlexStr<'s, [u8], R>

Available on crate feature bytes only.
Source§

fn from(s: &'s str) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<OsStr>> From<&'s str> for FlexStr<'s, OsStr, R>

Available on crate features std and osstr only.
Source§

fn from(s: &'s str) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<Path>> From<&'s str> for FlexStr<'s, Path, R>

Available on crate features std and path only.
Source§

fn from(s: &'s str) -> Self

Converts to this type from the input type.
Source§

impl<'s, S: ?Sized + StringToFromBytes> From<Arc<S>> for FlexStr<'s, S, Arc<S>>
where Arc<S>: for<'a> From<&'a S>,

Source§

fn from(s: Arc<S>) -> Self

Converts to this type from the input type.
Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> From<Box<S>> for FlexStr<'s, S, R>

Source§

fn from(s: Box<S>) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<CStr>> From<CString> for FlexStr<'s, CStr, R>

Available on crate feature cstr only.
Source§

fn from(s: CString) -> Self

Converts to this type from the input type.
Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> From<Cow<'s, S>> for FlexStr<'s, S, R>
where Box<S>: From<S::Owned>,

Source§

fn from(s: Cow<'s, S>) -> Self

Converts to this type from the input type.
Source§

impl<'s, S: ?Sized + StringToFromBytes, R: RefCounted<S>> From<InlineFlexStr<S>> for FlexStr<'s, S, R>

Source§

fn from(s: InlineFlexStr<S>) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<OsStr>> From<OsString> for FlexStr<'s, OsStr, R>

Available on crate features std and osstr only.
Source§

fn from(s: OsString) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<Path>> From<OsString> for FlexStr<'s, Path, R>

Available on crate features std and path only.
Source§

fn from(s: OsString) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<OsStr>> From<PathBuf> for FlexStr<'s, OsStr, R>

Available on crate features std and osstr and path only.
Source§

fn from(p: PathBuf) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<Path>> From<PathBuf> for FlexStr<'s, Path, R>

Available on crate features std and path only.
Source§

fn from(p: PathBuf) -> Self

Converts to this type from the input type.
Source§

impl<'s, S: ?Sized + StringToFromBytes> From<Rc<S>> for FlexStr<'s, S, Rc<S>>
where Rc<S>: for<'a> From<&'a S>,

Source§

fn from(s: Rc<S>) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<OsStr>> From<String> for FlexStr<'s, OsStr, R>

Available on crate features std and osstr only.
Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<Path>> From<String> for FlexStr<'s, Path, R>

Available on crate features std and path only.
Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<str>> From<String> for FlexStr<'s, str, R>

Available on crate feature str only.
Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl<'s, R: RefCounted<[u8]>> From<Vec<u8>> for FlexStr<'s, [u8], R>

Available on crate feature bytes only.
Source§

fn from(v: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl<R: RefCounted<[u8]>> FromStr for FlexStr<'static, [u8], R>

Available on crate feature bytes only.
Source§

type Err = Infallible

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<R: RefCounted<CStr>> FromStr for FlexStr<'static, CStr, R>

Available on crate feature cstr only.
Source§

type Err = InteriorNulError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<R: RefCounted<OsStr>> FromStr for FlexStr<'static, OsStr, R>

Available on crate features std and osstr only.
Source§

type Err = Infallible

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<R: RefCounted<Path>> FromStr for FlexStr<'static, Path, R>

Available on crate features std and path only.
Source§

type Err = Infallible

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<R: RefCounted<str>> FromStr for FlexStr<'static, str, R>

Available on crate feature str only.
Source§

type Err = Infallible

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<'s, S, R: RefCounted<S>> Hash for FlexStr<'s, S, R>

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<'s, S, R: RefCounted<S>, I: SliceIndex<S>> Index<I> for FlexStr<'s, S, R>
where S: Index<I> + ?Sized + StringToFromBytes,

Source§

type Output = <S as Index<I>>::Output

The returned type after indexing.
Source§

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

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

impl<'s, S, R: RefCounted<S>> Ord for FlexStr<'s, S, R>
where S: Ord + ?Sized + StringToFromBytes,

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'s, S, R: RefCounted<S>> PartialEq<&[u8]> for FlexStr<'s, S, R>

Available on crate feature bytes only.
Source§

fn eq(&self, other: &&[u8]) -> 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<'s, S, R: RefCounted<S>> PartialEq<&CStr> for FlexStr<'s, S, R>

Available on crate feature cstr only.
Source§

fn eq(&self, other: &&CStr) -> 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<'s, S, R: RefCounted<S>> PartialEq<&OsStr> for FlexStr<'s, S, R>

Available on crate features std and osstr only.
Source§

fn eq(&self, other: &&OsStr) -> 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<'s, S, R: RefCounted<S>> PartialEq<&Path> for FlexStr<'s, S, R>

Available on crate features std and path only.
Source§

fn eq(&self, other: &&Path) -> 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<'s, S, R: RefCounted<S>> PartialEq<&str> for FlexStr<'s, S, R>

Available on crate feature str only.
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<'s, S, R: RefCounted<S>> PartialEq<[u8]> for FlexStr<'s, S, R>

Available on crate feature bytes only.
Source§

fn eq(&self, other: &[u8]) -> 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<'s, S, R: RefCounted<S>> PartialEq<CStr> for FlexStr<'s, S, R>

Available on crate feature cstr only.
Source§

fn eq(&self, other: &CStr) -> 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<'s, S, R: RefCounted<S>> PartialEq<CString> for FlexStr<'s, S, R>

Available on crate feature cstr only.
Source§

fn eq(&self, other: &CString) -> 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<'s, S, R: RefCounted<S>> PartialEq<Cow<'s, [u8]>> for FlexStr<'s, S, R>

Available on crate feature bytes only.
Source§

fn eq(&self, other: &Cow<'s, [u8]>) -> 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<'s, S, R: RefCounted<S>> PartialEq<Cow<'s, CStr>> for FlexStr<'s, S, R>

Available on crate feature cstr only.
Source§

fn eq(&self, other: &Cow<'s, CStr>) -> 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<'s, S, R: RefCounted<S>> PartialEq<Cow<'s, OsStr>> for FlexStr<'s, S, R>

Available on crate features std and osstr only.
Source§

fn eq(&self, other: &Cow<'s, OsStr>) -> 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<'s, S, R: RefCounted<S>> PartialEq<Cow<'s, Path>> for FlexStr<'s, S, R>

Available on crate features std and path only.
Source§

fn eq(&self, other: &Cow<'s, Path>) -> 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<'s, S, R: RefCounted<S>> PartialEq<Cow<'s, str>> for FlexStr<'s, S, R>

Available on crate feature str only.
Source§

fn eq(&self, other: &Cow<'s, 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for &[u8]

Available on crate feature bytes only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for &CStr

Available on crate feature cstr only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for &OsStr

Available on crate features std and osstr only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for &Path

Available on crate features std and path only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for &str

Available on crate feature str only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for [u8]

Available on crate feature bytes only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for CStr

Available on crate feature cstr only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for CString

Available on crate feature cstr only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for Cow<'s, [u8]>

Available on crate feature bytes only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for Cow<'s, CStr>

Available on crate feature cstr only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for Cow<'s, OsStr>

Available on crate features std and osstr only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for Cow<'s, Path>

Available on crate features std and path only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for Cow<'s, str>

Available on crate feature str only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for OsStr

Available on crate features std and osstr only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for OsString

Available on crate features std and osstr only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for Path

Available on crate features std and path only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for PathBuf

Available on crate features std and path only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for String

Available on crate feature str only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for Vec<u8>

Available on crate feature bytes only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<FlexStr<'s, S, R>> for str

Available on crate feature str only.
Source§

fn eq(&self, other: &FlexStr<'s, S, R>) -> 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<'s, S, R: RefCounted<S>> PartialEq<OsStr> for FlexStr<'s, S, R>

Available on crate features std and osstr only.
Source§

fn eq(&self, other: &OsStr) -> 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<'s, S, R: RefCounted<S>> PartialEq<OsString> for FlexStr<'s, S, R>

Available on crate features std and osstr only.
Source§

fn eq(&self, other: &OsString) -> 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<'s, S, R: RefCounted<S>> PartialEq<Path> for FlexStr<'s, S, R>

Available on crate features std and path only.
Source§

fn eq(&self, other: &Path) -> 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<'s, S, R: RefCounted<S>> PartialEq<PathBuf> for FlexStr<'s, S, R>

Available on crate features std and path only.
Source§

fn eq(&self, other: &PathBuf) -> 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<'s, S, R: RefCounted<S>> PartialEq<String> for FlexStr<'s, S, R>

Available on crate feature str only.
Source§

fn eq(&self, other: &String) -> 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<'s, S, R: RefCounted<S>> PartialEq<Vec<u8>> for FlexStr<'s, S, R>

Available on crate feature bytes only.
Source§

fn eq(&self, other: &Vec<u8>) -> 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<'s, S, R: RefCounted<S>> PartialEq<str> for FlexStr<'s, S, R>

Available on crate feature str only.
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<'s, S, R: RefCounted<S>> PartialEq for FlexStr<'s, S, R>

Source§

fn eq(&self, other: &Self) -> 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<'s, S, R: RefCounted<S>> PartialOrd for FlexStr<'s, S, R>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'s, S, R: RefCounted<S>> Serialize for FlexStr<'s, S, R>

Available on crate feature serde only.
Source§

fn serialize<SER: Serializer>( &self, serializer: SER, ) -> Result<SER::Ok, SER::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl<S: ?Sized + StringToFromBytes, R: RefCounted<S>> StringLike<S> for FlexStr<'_, S, R>

Source§

fn as_ref_type(&self) -> &S

Borrow a string reference as &S
Source§

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

Borrow the string as bytes
Source§

fn into_owned_type(self) -> S::Owned
where S::Owned: From<Box<S>>,

Consume a string and convert it to an owned string. S::to_owned is called on Borrowed/Inlined/RefCounted variants. Boxed variants are converted directly into S::Owned (most likely without copy or allocation).
Source§

fn to_owned_type(&self) -> S::Owned

Convert a string reference to an owned string. S::to_owned is called on all variants.
Source§

fn is_empty(&self) -> bool

Returns true if this is an empty string
Source§

fn len(&self) -> usize

Returns the length of this string in bytes
Source§

fn as_str(&self) -> &str
where S: AsRef<str>,

Borrow the string as an &str
Source§

fn as_os_str(&self) -> &OsStr
where S: AsRef<OsStr>,

Available on crate features std and osstr only.
Borrow the string as an &OsStr
Source§

fn as_path(&self) -> &Path
where S: AsRef<Path>,

Available on crate features std and path only.
Borrow the string as a &Path
Source§

fn as_c_str(&self) -> &CStr
where S: AsRef<CStr>,

Available on crate feature cstr only.
Borrow the string as a &CStr
Source§

fn into_string(self) -> String
where <S as ToOwned>::Owned: Into<String> + From<Box<S>>,

Consume a string and convert it to a String
Source§

fn into_os_string(self) -> OsString
where <S as ToOwned>::Owned: Into<OsString> + From<Box<S>>,

Available on crate features std and osstr only.
Consume a string and convert it to an OsString
Source§

fn into_path_buf(self) -> PathBuf
where <S as ToOwned>::Owned: Into<PathBuf> + From<Box<S>>,

Available on crate features std and path only.
Consume a string and convert it to a PathBuf
Source§

fn into_c_string(self) -> CString
where <S as ToOwned>::Owned: Into<CString> + From<Box<S>>,

Available on crate feature cstr only.
Consume a string and convert it to a CString
Source§

fn into_vec_bytes(self) -> Vec<u8>
where <S as ToOwned>::Owned: Into<Vec<u8>> + From<Box<S>>,

Available on crate feature bytes only.
Consume a string and convert it to a Vec<u8>
Source§

fn to_string(&self) -> String
where <S as ToOwned>::Owned: Into<String>,

Convert a string reference to a String
Source§

fn to_os_string(&self) -> OsString
where <S as ToOwned>::Owned: Into<OsString>,

Available on crate features std and osstr only.
Convert a string reference to an OsString
Source§

fn to_path_buf(&self) -> PathBuf
where <S as ToOwned>::Owned: Into<PathBuf>,

Available on crate features std and path only.
Convert a string reference to a PathBuf
Source§

fn to_c_string(&self) -> CString
where <S as ToOwned>::Owned: Into<CString>,

Available on crate feature cstr only.
Convert a string reference to a CString
Source§

fn to_vec_bytes(&self) -> Vec<u8>
where <S as ToOwned>::Owned: Into<Vec<u8>>,

Available on crate feature bytes only.
Convert a string reference to a Vec<u8>
Source§

impl<'s, S, R: RefCounted<S>> ToSocketAddrs for FlexStr<'s, S, R>

Available on crate feature std only.
Source§

type Iter = <S as ToSocketAddrs>::Iter

Returned iterator over socket addresses which this type may correspond to.
Source§

fn to_socket_addrs(&self) -> Result<<S as ToSocketAddrs>::Iter>

Converts this object to an iterator of resolved SocketAddrs. Read more
Source§

impl<'s, R: RefCounted<CStr>> TryFrom<&'s [u8]> for FlexStr<'s, CStr, R>

Available on crate feature cstr only.
Source§

type Error = InteriorNulError

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &'s [u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'s, R: RefCounted<str>> TryFrom<&'s [u8]> for FlexStr<'s, str, R>

Available on crate feature str only.
Source§

type Error = Utf8Error

The type returned in the event of a conversion error.
Source§

fn try_from(s: &'s [u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'s, R: RefCounted<str>> TryFrom<&'s OsStr> for FlexStr<'s, str, R>

Available on crate features str and std only.
Source§

type Error = Utf8Error

The type returned in the event of a conversion error.
Source§

fn try_from(s: &'s OsStr) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'s, R: RefCounted<str>> TryFrom<&'s Path> for FlexStr<'s, str, R>

Available on crate features str and std only.
Source§

type Error = Utf8Error

The type returned in the event of a conversion error.
Source§

fn try_from(s: &'s Path) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'s, R: RefCounted<CStr>> TryFrom<&'s str> for FlexStr<'s, CStr, R>

Available on crate feature cstr only.
Source§

type Error = InteriorNulError

The type returned in the event of a conversion error.
Source§

fn try_from(s: &'s str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<R: RefCounted<str>> TryFrom<CString> for FlexStr<'static, str, R>

Available on crate feature str only.
Source§

type Error = IntoStringError

The type returned in the event of a conversion error.
Source§

fn try_from(s: CString) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<R: RefCounted<str>> TryFrom<Vec<u8>> for FlexStr<'static, str, R>

Available on crate feature str only.
Source§

type Error = FromUtf8Error

The type returned in the event of a conversion error.
Source§

fn try_from(s: Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'s, S, R: RefCounted<S>> Eq for FlexStr<'s, S, R>
where S: Eq + ?Sized + StringToFromBytes,

Auto Trait Implementations§

§

impl<'s, S, R> Freeze for FlexStr<'s, S, R>
where R: Freeze, S: ?Sized,

§

impl<'s, S, R> RefUnwindSafe for FlexStr<'s, S, R>

§

impl<'s, S, R> Send for FlexStr<'s, S, R>
where R: Send, S: Sync + Send + ?Sized,

§

impl<'s, S, R> Sync for FlexStr<'s, S, R>
where R: Sync, S: Sync + ?Sized,

§

impl<'s, S, R> Unpin for FlexStr<'s, S, R>
where R: Unpin, S: Unpin + ?Sized,

§

impl<'s, S, R> UnwindSafe for FlexStr<'s, S, R>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,