Struct uncased::UncasedStr [−][src]
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
[src]
pub fn new(string: &str) -> &UncasedStr
[src]
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!");
pub fn as_str(&self) -> &str
[src]
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!");
pub fn len(&self) -> usize
[src]
Returns the length, in bytes, of self
.
Example
use uncased::UncasedStr; let uncased_str = UncasedStr::new("Hello!"); assert_eq!(uncased_str.len(), 6);
pub fn is_empty(&self) -> bool
[src]
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
[src]
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>) -> Uncased<'static>
[src]
This is supported on crate feature
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
[src]
impl AsRef<UncasedStr> for Uncased<'_>
[src]
fn as_ref(&self) -> &UncasedStr
[src]
impl AsRef<str> for UncasedStr
[src]
impl Borrow<UncasedStr> for Uncased<'_>
[src]
fn borrow(&self) -> &UncasedStr
[src]
impl Debug for UncasedStr
[src]
impl Display for UncasedStr
[src]
impl Eq for UncasedStr
[src]
impl<'a> From<&'a str> for &'a UncasedStr
[src]
fn from(string: &'a str) -> &'a UncasedStr
[src]
impl<'s, 'c: 's> From<&'c UncasedStr> for Uncased<'s>
[src]
fn from(string: &'c UncasedStr) -> Self
[src]
impl Hash for UncasedStr
[src]
fn hash<H: Hasher>(&self, hasher: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<I: SliceIndex<str, Output = str>> Index<I> for UncasedStr
[src]
type Output = UncasedStr
The returned type after indexing.