use alloc::string::String; #[cfg(__unicase__iter_cmp)] use core::cmp::Ordering; use core::fmt; use core::hash::{Hash, Hasher}; use core::ops::{Deref, DerefMut}; use core::str::FromStr; #[cfg(not(__unicase__core_and_alloc))] #[allow(deprecated, unused)] use std::ascii::AsciiExt;
/// Construct a new `Ascii`. /// /// For Rust versions >= 1.31, this is a `const fn`. #[inline] #[cfg(not(__unicase__const_fns))] pub fn new(s: S) -> Ascii<S> {
Ascii(s)
}
impl<S: FromStr> FromStr for Ascii<S> { type Err = <S as FromStr>::Err;
fn from_str(s: &str) -> Result<Ascii<S>, <S as FromStr>::Err> {
s.parse().map(Ascii)
}
}
impl<S: AsRef<str>> Hash for Ascii<S> { #[inline]
fn hash<H: Hasher>(&self, hasher: &mut H) {
for byte in self.as_ref().bytes().map(|b| b.to_ascii_lowercase()) {
hasher.write_u8(byte);
}
}
}
#[cfg(test)] mod tests { use ::Ascii; use std::hash::{Hash, Hasher}; #[cfg(not(__unicase__default_hasher))] use std::hash::SipHasher as DefaultHasher; #[cfg(__unicase__default_hasher)] use std::collections::hash_map::DefaultHasher;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.