#[non_exhaustive]pub struct LanguagesDetect<'names> {
pub env: Option<HashMap<String, String>>,
pub names: Option<&'names [&'names str]>,
}
Expand description
Determine preferred languages as per the current locale settings.
This class is used to invoke the get_preferred_languages()
function
with reasonable default values: the current process environment and
the default LOCALE_VARIABLES
list of variable names, with the option
of overriding either.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.env: Option<HashMap<String, String>>
The environment variables to examine instead of std::env
.
names: Option<&'names [&'names str]>
The names of locale variables to use instead of the defaults.
Implementations§
Source§impl<'names> LanguagesDetect<'names>
impl<'names> LanguagesDetect<'names>
Sourcepub fn detect(self) -> Result<Vec<String>, UErr>
pub fn detect(self) -> Result<Vec<String>, UErr>
Detect the preferred languages according to the specified settings.
§Errors
Returns an error if one of the required environment variables has a value that is not a valid UTF-8 string.
Sourcepub fn with_env(self, env: HashMap<String, String>) -> Self
pub fn with_env(self, env: HashMap<String, String>) -> Self
Specify the environment variables to examine instead of std::env
.
Sourcepub fn with_names(self, names: &'names [&'names str]) -> Self
pub fn with_names(self, names: &'names [&'names str]) -> Self
Specify the names of the environment variables to look at instead of
LOCALE_VARIABLES
.
Trait Implementations§
Source§impl<'names> Debug for LanguagesDetect<'names>
impl<'names> Debug for LanguagesDetect<'names>
Source§impl<'names> Default for LanguagesDetect<'names>
impl<'names> Default for LanguagesDetect<'names>
Source§fn default() -> LanguagesDetect<'names>
fn default() -> LanguagesDetect<'names>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<'names> Freeze for LanguagesDetect<'names>
impl<'names> RefUnwindSafe for LanguagesDetect<'names>
impl<'names> Send for LanguagesDetect<'names>
impl<'names> Sync for LanguagesDetect<'names>
impl<'names> Unpin for LanguagesDetect<'names>
impl<'names> UnwindSafe for LanguagesDetect<'names>
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