pub struct Uncased<'s> { /* private fields */ }
Available on crate feature
alloc
only.Expand description
An uncased (case-insensitive, case-preserving), owned or borrowed ASCII string.
Implementations§
source§impl<'s> Uncased<'s>
impl<'s> Uncased<'s>
sourcepub fn new<S: Into<Cow<'s, str>>>(string: S) -> Uncased<'s>
pub fn new<S: Into<Cow<'s, str>>>(string: S) -> Uncased<'s>
Creates a new Uncased
string from string
without allocating.
Example
use uncased::Uncased;
let uncased = Uncased::new("Content-Type");
assert_eq!(uncased, "content-type");
assert_eq!(uncased, "CONTENT-Type");
sourcepub const fn from_borrowed(string: &'s str) -> Uncased<'s>
pub const fn from_borrowed(string: &'s str) -> Uncased<'s>
Creates a new Uncased
string from a borrowed string
.
Example
use uncased::Uncased;
const UNCASED: Uncased = Uncased::from_borrowed("Content-Type");
assert_eq!(UNCASED, "content-type");
assert_eq!(UNCASED, "CONTENT-Type");
sourcepub const fn from_owned(string: String) -> Uncased<'s>
pub const fn from_owned(string: String) -> Uncased<'s>
Creates a new Uncased
string from string
without allocating.
Example
use uncased::Uncased;
const UNCASED: Uncased = Uncased::from_owned(String::new());
let uncased = Uncased::from_owned("Content-Type".to_string());
assert_eq!(uncased, "content-type");
assert_eq!(uncased, "CONTENT-Type");
sourcepub fn as_uncased_str(&self) -> &UncasedStr
pub fn as_uncased_str(&self) -> &UncasedStr
Converts self
into an owned Uncased<'static>
, allocating if
necessary.
Example
use uncased::Uncased;
let foo = "foo".to_string();
let uncased = Uncased::from(foo.as_str());
let owned: Uncased<'static> = uncased.into_owned();
assert_eq!(owned, "foo");
sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Converts self
into an owned String
, allocating if necessary.
Example
use uncased::Uncased;
let uncased = Uncased::new("Content-Type");
let string = uncased.into_string();
assert_eq!(string, "Content-Type".to_string());
sourcepub fn into_owned(self) -> Uncased<'static>
pub fn into_owned(self) -> Uncased<'static>
Converts self
into an owned Uncased<'static>
, allocating if
necessary.
Example
use uncased::Uncased;
let foo = "foo".to_string();
let uncased = Uncased::from(foo.as_str());
let owned: Uncased<'static> = uncased.into_owned();
assert_eq!(owned, "foo");
sourcepub fn into_boxed_uncased(self) -> Box<UncasedStr>
pub fn into_boxed_uncased(self) -> Box<UncasedStr>
Converts self
into a Box<UncasedStr>
.
Example
use uncased::Uncased;
let boxed = Uncased::new("Content-Type").into_boxed_uncased();
assert_eq!(&*boxed, "content-type");
Methods from Deref<Target = UncasedStr>§
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
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!");
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length, in bytes, of self
.
Example
use uncased::UncasedStr;
let uncased_str = UncasedStr::new("Hello!");
assert_eq!(uncased_str.len(), 6);
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
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());
sourcepub 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"));
Trait Implementations§
source§impl AsRef<UncasedStr> for Uncased<'_>
impl AsRef<UncasedStr> for Uncased<'_>
source§fn as_ref(&self) -> &UncasedStr
fn as_ref(&self) -> &UncasedStr
Converts this type into a shared reference of the (usually inferred) input type.
source§impl Borrow<UncasedStr> for Uncased<'_>
impl Borrow<UncasedStr> for Uncased<'_>
source§fn borrow(&self) -> &UncasedStr
fn borrow(&self) -> &UncasedStr
Immutably borrows from an owned value. Read more
source§impl Deref for Uncased<'_>
impl Deref for Uncased<'_>
§type Target = UncasedStr
type Target = UncasedStr
The resulting type after dereferencing.
source§fn deref(&self) -> &UncasedStr
fn deref(&self) -> &UncasedStr
Dereferences the value.
source§impl<'a, 'de> Deserialize<'de> for Uncased<'a>
impl<'a, 'de> Deserialize<'de> for Uncased<'a>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<'s, 'c: 's> From<&'c UncasedStr> for Uncased<'s>
impl<'s, 'c: 's> From<&'c UncasedStr> for Uncased<'s>
source§fn from(string: &'c UncasedStr) -> Self
fn from(string: &'c UncasedStr) -> Self
Converts to this type from the input type.
source§impl Ord for Uncased<'_>
impl Ord for Uncased<'_>
source§impl PartialEq<&Uncased<'_>> for String
impl PartialEq<&Uncased<'_>> for String
source§impl PartialEq<&Uncased<'_>> for UncasedStr
impl PartialEq<&Uncased<'_>> for UncasedStr
source§impl PartialEq<&UncasedStr> for Uncased<'_>
impl PartialEq<&UncasedStr> for Uncased<'_>
source§fn eq(&self, other: &&UncasedStr) -> bool
fn eq(&self, other: &&UncasedStr) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<&str> for Uncased<'_>
impl PartialEq<&str> for Uncased<'_>
source§impl PartialEq<String> for &Uncased<'_>
impl PartialEq<String> for &Uncased<'_>
source§impl PartialEq<String> for Uncased<'_>
impl PartialEq<String> for Uncased<'_>
source§impl PartialEq<Uncased<'_>> for &UncasedStr
impl PartialEq<Uncased<'_>> for &UncasedStr
source§impl PartialEq<Uncased<'_>> for &str
impl PartialEq<Uncased<'_>> for &str
source§impl PartialEq<Uncased<'_>> for String
impl PartialEq<Uncased<'_>> for String
source§impl PartialEq<Uncased<'_>> for Uncased<'_>
impl PartialEq<Uncased<'_>> for Uncased<'_>
source§impl PartialEq<Uncased<'_>> for UncasedStr
impl PartialEq<Uncased<'_>> for UncasedStr
source§impl PartialEq<Uncased<'_>> for str
impl PartialEq<Uncased<'_>> for str
source§impl PartialEq<UncasedStr> for &Uncased<'_>
impl PartialEq<UncasedStr> for &Uncased<'_>
source§fn eq(&self, other: &UncasedStr) -> bool
fn eq(&self, other: &UncasedStr) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialEq<UncasedStr> for Uncased<'_>
impl PartialEq<UncasedStr> for Uncased<'_>
source§fn eq(&self, other: &UncasedStr) -> bool
fn eq(&self, other: &UncasedStr) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<&Uncased<'_>> for String
impl PartialOrd<&Uncased<'_>> for String
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<&Uncased<'_>> for UncasedStr
impl PartialOrd<&Uncased<'_>> for UncasedStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<&UncasedStr> for Uncased<'_>
impl PartialOrd<&UncasedStr> for Uncased<'_>
source§fn partial_cmp(&self, other: &&UncasedStr) -> Option<Ordering>
fn partial_cmp(&self, other: &&UncasedStr) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<String> for &Uncased<'_>
impl PartialOrd<String> for &Uncased<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<String> for Uncased<'_>
impl PartialOrd<String> for Uncased<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<Uncased<'_>> for &UncasedStr
impl PartialOrd<Uncased<'_>> for &UncasedStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<Uncased<'_>> for String
impl PartialOrd<Uncased<'_>> for String
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<Uncased<'_>> for Uncased<'_>
impl PartialOrd<Uncased<'_>> for Uncased<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<Uncased<'_>> for UncasedStr
impl PartialOrd<Uncased<'_>> for UncasedStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<Uncased<'_>> for str
impl PartialOrd<Uncased<'_>> for str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<UncasedStr> for &Uncased<'_>
impl PartialOrd<UncasedStr> for &Uncased<'_>
source§fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<UncasedStr> for Uncased<'_>
impl PartialOrd<UncasedStr> for Uncased<'_>
source§fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<str> for Uncased<'_>
impl PartialOrd<str> for Uncased<'_>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Uncased<'_>
Auto Trait Implementations§
impl<'s> RefUnwindSafe for Uncased<'s>
impl<'s> Send for Uncased<'s>
impl<'s> Sync for Uncased<'s>
impl<'s> Unpin for Uncased<'s>
impl<'s> UnwindSafe for Uncased<'s>
Blanket Implementations§
source§impl<T> AsUncased for Twhere
T: AsRef<str> + ?Sized,
impl<T> AsUncased for Twhere T: AsRef<str> + ?Sized,
source§fn as_uncased(&self) -> &UncasedStr
fn as_uncased(&self) -> &UncasedStr
Convert
self
to an UncasedStr
.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more