Struct uncased::UncasedStr
source · [−]#[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
sourceimpl UncasedStr
impl UncasedStr
sourcepub 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!");
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
sourceimpl Debug for UncasedStr
impl Debug for UncasedStr
sourceimpl Display for UncasedStr
impl Display for UncasedStr
sourceimpl<'a> From<&'a str> for &'a UncasedStr
impl<'a> From<&'a str> for &'a UncasedStr
sourcefn from(string: &'a str) -> &'a UncasedStr
fn from(string: &'a str) -> &'a UncasedStr
Performs the conversion.
sourceimpl Hash for UncasedStr
impl Hash for UncasedStr
sourceimpl<I: SliceIndex<str, Output = str>> Index<I> for UncasedStr
impl<I: SliceIndex<str, Output = str>> Index<I> for UncasedStr
sourceimpl Ord for UncasedStr
impl Ord for UncasedStr
sourceimpl PartialEq<&'_ UncasedStr> for str
impl PartialEq<&'_ UncasedStr> for str
sourceimpl PartialEq<&'_ str> for UncasedStr
impl PartialEq<&'_ str> for UncasedStr
sourceimpl PartialEq<UncasedStr> for UncasedStr
impl PartialEq<UncasedStr> for UncasedStr
sourceimpl PartialEq<UncasedStr> for str
impl PartialEq<UncasedStr> for str
sourceimpl PartialEq<UncasedStr> for &str
impl PartialEq<UncasedStr> for &str
sourceimpl PartialEq<str> for UncasedStr
impl PartialEq<str> for UncasedStr
sourceimpl PartialEq<str> for &UncasedStr
impl PartialEq<str> for &UncasedStr
sourceimpl PartialOrd<UncasedStr> for UncasedStr
impl PartialOrd<UncasedStr> for UncasedStr
sourcefn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
sourceimpl PartialOrd<UncasedStr> for str
impl PartialOrd<UncasedStr> for str
sourcefn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
fn partial_cmp(&self, other: &UncasedStr) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
sourceimpl PartialOrd<str> for UncasedStr
impl PartialOrd<str> for UncasedStr
sourcefn partial_cmp(&self, other: &str) -> Option<Ordering>
fn partial_cmp(&self, other: &str) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more