pub struct LowerStr(/* private fields */);Expand description
A borrowed reference to a non-empty, lowercase string
A non-empty String normalized to lowercase
This type maintains an invariant that ensures that a value of this type cannot be constructed that contains invalid data. Data that can be normalized to a valid instance of this type will be.
Because this type does normalization, the type explicitly
does not implement Borrow<str>,
as doing so would could violate the contract of that trait,
potentially resulting in lost data. If a user of
the crate would like to override this, then they can
explicitly implement the trait.
This type includes an explicit parameter indicating that
the borrowed form of this type should be named LowerStr.
Implementations§
Source§impl LowerStr
impl LowerStr
Sourcepub fn from_normalized_str(
raw: &str,
) -> Result<&Self, <LowerString as Validator>::Error>
pub fn from_normalized_str( raw: &str, ) -> Result<&Self, <LowerString as Validator>::Error>
Transparently reinterprets the string slice as a strongly-typed LowerStr if it conforms to LowerString, producing an error if normalization is necessary
Sourcepub const unsafe fn from_str_unchecked(raw: &str) -> &Self
pub const unsafe fn from_str_unchecked(raw: &str) -> &Self
Transparently reinterprets the string slice as a strongly-typed LowerStr without validating
§Safety
Calls to this function must ensure that the value being passed conforms to LowerString and is already in normalized form. Failure to do this may result in undefined behavior if other code relies on this invariant.
Sourcepub fn from_static(raw: &'static str) -> &'static Self
pub fn from_static(raw: &'static str) -> &'static Self
Transparently reinterprets a static string slice as a strongly-typed LowerStr if it conforms to LowerString, normalizing if necessary
§Panics
This function will panic if the provided raw string is not normalized.
Sourcepub fn from_str(
raw: &str,
) -> Result<Cow<'_, Self>, <LowerString as Validator>::Error>
pub fn from_str( raw: &str, ) -> Result<Cow<'_, Self>, <LowerString as Validator>::Error>
Transparently reinterprets the string slice as a strongly-typed LowerStr if it conforms to LowerString, normalizing if necessary
Sourcepub fn into_owned(self: Box<LowerStr>) -> LowerString
pub fn into_owned(self: Box<LowerStr>) -> LowerString
Converts a Box<LowerStr> into a LowerString without copying or allocating
Trait Implementations§
Source§impl AsRef<LowerStr> for LowerString
impl AsRef<LowerStr> for LowerString
Source§impl Borrow<LowerStr> for LowerString
impl Borrow<LowerStr> for LowerString
Source§impl<'de: 'a, 'a> Deserialize<'de> for &'a LowerStr
Deserializes a LowerStr in normalized form
impl<'de: 'a, 'a> Deserialize<'de> for &'a LowerStr
Deserializes a LowerStr in normalized form
This deserializer requires that the value already be in normalized form. If values may require normalization, then deserialized as LowerString or Cow<LowerStr> instead.