pub enum Dialect {
American = 1,
Canadian = 2,
Australian = 4,
British = 8,
}
Expand description
A regional dialect.
Variants§
Implementations§
Source§impl Dialect
impl Dialect
Sourcepub fn try_guess_from_document(document: &Document) -> Option<Self>
pub fn try_guess_from_document(document: &Document) -> Option<Self>
Tries to guess the dialect used in the document by finding which dialect is used the most.
Returns None
if it fails to find a single dialect that is used the most.
Sourcepub fn try_from_abbr(abbr: &str) -> Option<Self>
pub fn try_from_abbr(abbr: &str) -> Option<Self>
Tries to get a dialect from its abbreviation. Returns None
if the abbreviation is not
recognized.
§Examples
use harper_core::Dialect;
let abbrs = ["US", "CA", "AU", "GB"];
let mut dialects = abbrs.iter().map(|abbr| Dialect::try_from_abbr(abbr));
assert_eq!(Some(Dialect::American), dialects.next().unwrap()); // US
assert_eq!(Some(Dialect::Canadian), dialects.next().unwrap()); // CA
assert_eq!(Some(Dialect::Australian), dialects.next().unwrap()); // AU
assert_eq!(Some(Dialect::British), dialects.next().unwrap()); // GB
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Dialect
impl<'de> Deserialize<'de> for Dialect
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialOrd for Dialect
impl PartialOrd for Dialect
impl Copy for Dialect
impl Eq for Dialect
impl StructuralPartialEq for Dialect
Auto Trait Implementations§
impl Freeze for Dialect
impl RefUnwindSafe for Dialect
impl Send for Dialect
impl Sync for Dialect
impl Unpin for Dialect
impl UnwindSafe for Dialect
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,
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
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
Converts
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>
Converts
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 more