pub struct LocaleData {
pub name: String,
pub args: HashMap<String, LocaleValue>,
}
Expand description
Represents the localization data for a specific locale. This structure holds locale-specific information, such as the locale’s name and associated arguments or values used for localization.
Fields§
§name: String
§args: HashMap<String, LocaleValue>
Implementations§
Source§impl LocaleData
impl LocaleData
Sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Creates a new instance of the struct with the provided name.
§Parameters
name
: A string slice that represents the name to associate with the instance.
§Returns
Returns a new instance of the struct, where the name
field is initialized
with the provided value and the args
field is set to its default value.
§Example
use cjtoolkit_structured_validator::common::locale::LocaleData;
let instance = LocaleData::new("example");
Sourcepub fn new_with_vec(name: &str, args: Vec<(String, LocaleValue)>) -> Self
pub fn new_with_vec(name: &str, args: Vec<(String, LocaleValue)>) -> Self
Creates a new instance of the structure using a name and a vector of key-value pairs.
§Arguments
name
- A string slice representing the name for the new instance.args
- A vector containing tuples, where each tuple consists of aString
(key) and aLocaleValue
(value). These key-value pairs will be used to initialize the args map of the structure.
§Returns
A new instance of the structure is populated with the provided name
and args
.
§Example
use cjtoolkit_structured_validator::common::locale::LocaleData;
use cjtoolkit_structured_validator::common::locale::LocaleValue;
let instance = LocaleData::new_with_vec("example_name", vec![
("key1".to_string(), LocaleValue::from("value1")),
("key2".to_string(), LocaleValue::from("value2")),
]);
assert_eq!(instance.name, "example_name");
assert!(instance.args.contains_key("key1"));
Auto Trait Implementations§
impl Freeze for LocaleData
impl RefUnwindSafe for LocaleData
impl Send for LocaleData
impl Sync for LocaleData
impl Unpin for LocaleData
impl UnwindSafe for LocaleData
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