Struct rocket::http::uncased::UncasedStr [−]
#[repr(transparent)]pub struct UncasedStr(_);
Expand description
A cost-free reference to an uncased (case-insensitive, case-preserving) ASCII string.
This is typically created from an &str
as follows:
use uncased::UncasedStr; let ascii_ref: &UncasedStr = "Hello, world!".into();
Implementations
impl UncasedStr
impl UncasedStr
pub fn new(string: &str) -> &UncasedStr
pub fn new(string: &str) -> &UncasedStr
Cost-free conversion from an &str
reference to an UncasedStr
.
Example
use uncased::UncasedStr; let uncased_str = UncasedStr::new("Hello!"); assert_eq!(uncased_str, "hello!"); assert_eq!(uncased_str, "Hello!"); assert_eq!(uncased_str, "HeLLo!");
Returns self
as an &str
.
Example
use uncased::UncasedStr; let uncased_str = UncasedStr::new("Hello!"); assert_eq!(uncased_str.as_str(), "Hello!"); assert_ne!(uncased_str.as_str(), "hELLo!");
Returns the length, in bytes, of self
.
Example
use uncased::UncasedStr; let uncased_str = UncasedStr::new("Hello!"); assert_eq!(uncased_str.len(), 6);
Returns true
if self
has a length of zero bytes.
Examples
use uncased::UncasedStr; let s = UncasedStr::new(""); assert!(s.is_empty()); let s = UncasedStr::new("not empty"); assert!(!s.is_empty());
pub fn starts_with(&self, string: &str) -> bool
pub fn starts_with(&self, string: &str) -> bool
Returns true
if self
starts with any casing of the string string
;
otherwise, returns false
.
Example
use uncased::UncasedStr; let uncased_str = UncasedStr::new("MoOO"); assert!(uncased_str.starts_with("moo")); assert!(uncased_str.starts_with("MOO")); assert!(uncased_str.starts_with("MOOO")); assert!(!uncased_str.starts_with("boo")); let uncased_str = UncasedStr::new("Bèe"); assert!(!uncased_str.starts_with("Be")); assert!(uncased_str.starts_with("Bè")); assert!(uncased_str.starts_with("Bè")); assert!(uncased_str.starts_with("bèe")); assert!(uncased_str.starts_with("BèE"));
pub fn into_uncased(self: Box<UncasedStr, Global>) -> Uncased<'static>
This is supported on crate feature alloc
only.
pub fn into_uncased(self: Box<UncasedStr, Global>) -> Uncased<'static>
alloc
only.Converts a Box<UncasedStr>
into an Uncased
without copying or
allocating.
Example
use uncased::Uncased; let uncased = Uncased::new("Hello!"); let boxed = uncased.clone().into_boxed_uncased(); assert_eq!(boxed.into_uncased(), uncased);
Trait Implementations
impl AsRef<[u8]> for UncasedStr
impl AsRef<[u8]> for UncasedStr
impl<'_> AsRef<UncasedStr> for Uncased<'_>
impl<'_> AsRef<UncasedStr> for Uncased<'_>
pub fn as_ref(&self) -> &UncasedStr
pub fn as_ref(&self) -> &UncasedStr
Performs the conversion.
impl AsRef<str> for UncasedStr
impl AsRef<str> for UncasedStr
impl<'_> Borrow<UncasedStr> for Uncased<'_>
impl<'_> Borrow<UncasedStr> for Uncased<'_>
pub fn borrow(&self) -> &UncasedStr
pub fn borrow(&self) -> &UncasedStr
Immutably borrows from an owned value. Read more
impl Debug for UncasedStr
impl Debug for UncasedStr
impl<'a, 'de> Deserialize<'de> for &'a UncasedStr where
'de: 'a,
impl<'a, 'de> Deserialize<'de> for &'a UncasedStr where
'de: 'a,
pub fn deserialize<D>(
deserializer: D
) -> Result<&'a UncasedStr, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub fn deserialize<D>(
deserializer: D
) -> Result<&'a UncasedStr, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Display for UncasedStr
impl Display for UncasedStr
impl<'a> From<&'a str> for &'a UncasedStr
impl<'a> From<&'a str> for &'a UncasedStr
pub fn from(string: &'a str) -> &'a UncasedStr
pub fn from(string: &'a str) -> &'a UncasedStr
Performs the conversion.
impl<'s, 'c> From<&'c UncasedStr> for Uncased<'s> where
'c: 's,
impl<'s, 'c> From<&'c UncasedStr> for Uncased<'s> where
'c: 's,
pub fn from(string: &'c UncasedStr) -> Uncased<'s>
pub fn from(string: &'c UncasedStr) -> Uncased<'s>
Performs the conversion.
impl Hash for UncasedStr
impl Hash for UncasedStr
impl<I> Index<I> for UncasedStr where
I: SliceIndex<str, Output = str>,
impl<I> Index<I> for UncasedStr where
I: SliceIndex<str, Output = str>,
type Output = UncasedStr
type Output = UncasedStr
The returned type after indexing.
pub fn index(&self, index: I) -> &<UncasedStr as Index<I>>::Output
pub fn index(&self, index: I) -> &<UncasedStr as Index<I>>::Output
Performs the indexing (container[index]
) operation. Read more
impl Ord for UncasedStr
impl Ord for UncasedStr
pub fn cmp(&self, other: &UncasedStr) -> Ordering
pub fn cmp(&self, other: &UncasedStr) -> Ordering
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
impl<'_> PartialEq<&'_ UncasedStr> for str
impl<'_> PartialEq<&'_ UncasedStr> for str
impl<'_> PartialEq<&'_ str> for UncasedStr
impl<'_> PartialEq<&'_ str> for UncasedStr
impl PartialEq<String> for UncasedStr
impl PartialEq<String> for UncasedStr
impl PartialEq<UncasedStr> for str
impl PartialEq<UncasedStr> for str
impl<'_> PartialEq<UncasedStr> for &'_ str
impl<'_> PartialEq<UncasedStr> for &'_ str
impl PartialEq<UncasedStr> for UncasedStr
impl PartialEq<UncasedStr> for UncasedStr
impl PartialEq<str> for UncasedStr
impl PartialEq<str> for UncasedStr
impl<'_> PartialEq<str> for &'_ UncasedStr
impl<'_> PartialEq<str> for &'_ UncasedStr
impl PartialOrd<String> for UncasedStr
impl PartialOrd<String> for UncasedStr
pub fn partial_cmp(&self, other: &String) -> Option<Ordering>
pub fn partial_cmp(&self, other: &String) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
impl PartialOrd<UncasedStr> for UncasedStr
impl PartialOrd<UncasedStr> for UncasedStr
pub fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
pub fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
impl PartialOrd<UncasedStr> for str
impl PartialOrd<UncasedStr> for str
pub fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
pub fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
impl PartialOrd<str> for UncasedStr
impl PartialOrd<str> for UncasedStr
pub fn partial_cmp(&self, other: &str) -> Option<Ordering>
pub fn partial_cmp(&self, other: &str) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
impl<'a> Serialize for &'a UncasedStr
impl<'a> Serialize for &'a UncasedStr
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for UncasedStr
Auto Trait Implementations
impl RefUnwindSafe for UncasedStr
impl Send for UncasedStr
impl !Sized for UncasedStr
impl Sync for UncasedStr
impl Unpin for UncasedStr
impl UnwindSafe for UncasedStr
Blanket Implementations
pub fn as_uncased(&self) -> &UncasedStr
pub fn as_uncased(&self) -> &UncasedStr
Convert self
to an UncasedStr
.
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.