Struct uncased::UncasedStr[][src]

#[repr(transparent)]pub struct UncasedStr(_);

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]

impl AsRef<str> for UncasedStr[src]

impl Borrow<UncasedStr> for Uncased<'_>[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]

impl<'s, 'c: 's> From<&'c UncasedStr> for Uncased<'s>[src]

impl Hash for UncasedStr[src]

impl<I: SliceIndex<str, Output = str>> Index<I> for UncasedStr[src]

type Output = UncasedStr

The returned type after indexing.

impl Ord for UncasedStr[src]

impl PartialEq<&'_ str> for UncasedStr[src]

impl PartialEq<String> for UncasedStr[src]

impl PartialEq<UncasedStr> for UncasedStr[src]

impl PartialEq<str> for UncasedStr[src]

impl PartialEq<str> for &UncasedStr[src]

impl PartialOrd<String> for UncasedStr[src]

impl PartialOrd<UncasedStr> for UncasedStr[src]

impl PartialOrd<str> for UncasedStr[src]

Auto Trait Implementations

impl Send for UncasedStr

impl !Sized for UncasedStr

impl Sync for UncasedStr

impl Unpin for UncasedStr

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]