pub struct LanguageRange(/* private fields */);Expand description
An RFC 4647 §2.1 basic language range: "*", or a primary subtag
of 1 to 8 letters followed by subtags of 1 to 8 letters or digits.
Held in the canonical case of a LanguageTag (RFC 5646 §2.1.1),
so that equal ranges render equally; matching ignores case either
way (RFC 4647 §2).
use jmap_types::i18n::LanguageRange;
let r: LanguageRange = "DE-ch".parse().unwrap();
assert_eq!(r.as_str(), "de-CH");
assert!("*".parse::<LanguageRange>().unwrap().is_wildcard());Implementations§
Source§impl LanguageRange
impl LanguageRange
Sourcepub fn parse(s: &str) -> Result<Self, LanguageTagError>
pub fn parse(s: &str) -> Result<Self, LanguageTagError>
Parse s as an RFC 4647 §2.1 language-range.
§Errors
LanguageTagError when s is not a basic language range.
Sourcepub fn is_wildcard(&self) -> bool
pub fn is_wildcard(&self) -> bool
true for the wildcard range "*".
Trait Implementations§
Source§impl Clone for LanguageRange
impl Clone for LanguageRange
Source§impl Debug for LanguageRange
impl Debug for LanguageRange
Source§impl<'de> Deserialize<'de> for LanguageRange
impl<'de> Deserialize<'de> for LanguageRange
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for LanguageRange
impl Display for LanguageRange
impl Eq for LanguageRange
Source§impl FromStr for LanguageRange
impl FromStr for LanguageRange
Source§impl Hash for LanguageRange
impl Hash for LanguageRange
Source§impl Ord for LanguageRange
impl Ord for LanguageRange
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialEq for LanguageRange
impl PartialEq for LanguageRange
Source§impl PartialOrd for LanguageRange
impl PartialOrd for LanguageRange
Source§impl Serialize for LanguageRange
impl Serialize for LanguageRange
impl StructuralPartialEq for LanguageRange
Auto Trait Implementations§
impl Forget for LanguageRange
impl Freeze for LanguageRange
impl Move for LanguageRange
impl RefUnwindSafe for LanguageRange
impl Send for LanguageRange
impl Sync for LanguageRange
impl Unpin for LanguageRange
impl UnsafeUnpin for LanguageRange
impl UnwindSafe for LanguageRange
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.