pub struct Str<'k> { /* private fields */ }Expand description
Implementations§
Source§impl<'k> Str<'k>
impl<'k> Str<'k>
Sourcepub const fn new_ref(k: &'k str) -> Str<'k>
pub const fn new_ref(k: &'k str) -> Str<'k>
Create a new string from a value borrowed for 'k.
The Str::new method should be preferred where possible.
Sourcepub const fn get_static(&self) -> Option<&'static str>
pub const fn get_static(&self) -> Option<&'static str>
Try get a reference to the underlying static value.
If the string was created from Str::new and contains a 'static value then this method will return Some. Otherwise this method will return None.
Source§impl<'k> Str<'k>
impl<'k> Str<'k>
Sourcepub fn new_cow_ref(key: Cow<'k, str>) -> Str<'k>
pub fn new_cow_ref(key: Cow<'k, str>) -> Str<'k>
Create a string from a potentially owned value.
If the value is Cow::Borrowed then this method will defer to Str::new_ref. If the value is Cow::Owned then this method will defer to Str::new_owned.
Sourcepub fn to_cow(&self) -> Cow<'static, str>
pub fn to_cow(&self) -> Cow<'static, str>
Get the underlying value as a potentially owned string.
If the string contains a 'static value then this method will return Cow::Borrowed. Otherwise it will return Cow::Owned.
Sourcepub fn to_owned(&self) -> Str<'static>
pub fn to_owned(&self) -> Str<'static>
Get a new string, taking an owned copy of the data in this one.
If the string contains a 'static or Arc value then this method is cheap and doesn’t involve cloning. In other cases the underlying value will be passed through Str::new_owned.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Convert this string into an owned String.
If the underlying value is already an owned string then this method will return it without allocating.
Get a new string, taking an owned copy of the data in this one.
If the string contains a 'static or Arc value then this method is cheap and doesn’t involve cloning. In other cases the underlying value will be passed through Str::new_shared.
Trait Implementations§
Source§impl<'a> Ord for Str<'a>
impl<'a> Ord for Str<'a>
Source§impl<'a, 'b> PartialOrd<Str<'b>> for Str<'a>
impl<'a, 'b> PartialOrd<Str<'b>> for Str<'a>
Source§impl<'k> Serialize for Str<'k>
impl<'k> Serialize for Str<'k>
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl<'k> Value for Str<'k>
impl<'k> Value for Str<'k>
Source§fn stream<'sval, S>(&'sval self, stream: &mut S) -> Result<(), Error>
fn stream<'sval, S>(&'sval self, stream: &mut S) -> Result<(), Error>
Stream.