pub struct Uncased<'s> { /* private fields */ }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>(string: S) -> Uncased<'s>
pub fn new<S>(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
Source§impl Borrow<UncasedStr> for Uncased<'_>
impl Borrow<UncasedStr> for Uncased<'_>
Source§fn borrow(&self) -> &UncasedStr
fn borrow(&self) -> &UncasedStr
Source§impl Deref for Uncased<'_>
impl Deref for Uncased<'_>
Source§type Target = UncasedStr
type Target = UncasedStr
Source§fn deref(&self) -> &UncasedStr
fn deref(&self) -> &UncasedStr
Source§impl<'a, 'de> Deserialize<'de> for Uncased<'a>
impl<'a, 'de> Deserialize<'de> for Uncased<'a>
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Uncased<'a>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Uncased<'a>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<'s, 'c> From<&'c UncasedStr> for Uncased<'s>where
'c: 's,
impl<'s, 'c> From<&'c UncasedStr> for Uncased<'s>where
'c: 's,
Source§fn from(string: &'c UncasedStr) -> Uncased<'s>
fn from(string: &'c UncasedStr) -> Uncased<'s>
Source§impl Ord for Uncased<'_>
impl Ord for Uncased<'_>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq<&Uncased<'_>> for UncasedStr
impl PartialEq<&Uncased<'_>> for UncasedStr
Source§impl PartialEq<&UncasedStr> for Uncased<'_>
impl PartialEq<&UncasedStr> for Uncased<'_>
Source§impl PartialEq<Uncased<'_>> for &UncasedStr
impl PartialEq<Uncased<'_>> for &UncasedStr
Source§impl PartialEq<Uncased<'_>> for UncasedStr
impl PartialEq<Uncased<'_>> for UncasedStr
Source§impl PartialEq<UncasedStr> for &Uncased<'_>
impl PartialEq<UncasedStr> for &Uncased<'_>
Source§impl PartialEq<UncasedStr> for Uncased<'_>
impl PartialEq<UncasedStr> for Uncased<'_>
Source§impl PartialOrd<&Uncased<'_>> for String
impl PartialOrd<&Uncased<'_>> for String
Source§impl PartialOrd<&Uncased<'_>> for UncasedStr
impl PartialOrd<&Uncased<'_>> for UncasedStr
Source§impl PartialOrd<&UncasedStr> for Uncased<'_>
impl PartialOrd<&UncasedStr> for Uncased<'_>
Source§impl PartialOrd<String> for &Uncased<'_>
impl PartialOrd<String> for &Uncased<'_>
Source§impl PartialOrd<String> for Uncased<'_>
impl PartialOrd<String> for Uncased<'_>
Source§impl PartialOrd<Uncased<'_>> for &UncasedStr
impl PartialOrd<Uncased<'_>> for &UncasedStr
Source§impl PartialOrd<Uncased<'_>> for String
impl PartialOrd<Uncased<'_>> for String
Source§impl PartialOrd<Uncased<'_>> for Uncased<'_>
impl PartialOrd<Uncased<'_>> for Uncased<'_>
Source§impl PartialOrd<Uncased<'_>> for UncasedStr
impl PartialOrd<Uncased<'_>> for UncasedStr
Source§impl PartialOrd<Uncased<'_>> for str
impl PartialOrd<Uncased<'_>> for str
Source§impl PartialOrd<UncasedStr> for &Uncased<'_>
impl PartialOrd<UncasedStr> for &Uncased<'_>
Source§impl PartialOrd<UncasedStr> for Uncased<'_>
impl PartialOrd<UncasedStr> for Uncased<'_>
Source§impl PartialOrd<str> for Uncased<'_>
impl PartialOrd<str> for Uncased<'_>
Source§impl<'a> Serialize for Uncased<'a>
impl<'a> Serialize for Uncased<'a>
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for Uncased<'_>
Auto Trait Implementations§
impl<'s> Freeze for Uncased<'s>
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> AsAny for Twhere
T: Any,
impl<T> AsAny for Twhere
T: Any,
fn as_any_ref(&self) -> &(dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> AsUncased for T
impl<T> AsUncased for T
Source§fn as_uncased(&self) -> &UncasedStr
fn as_uncased(&self) -> &UncasedStr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);