diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..8b7ee75 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1652507842344 + + + + \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index b7b956b..45b3641 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -498,12 +498,12 @@ impl Locale { pub fn new(s: &str) -> Result { let mut i = s.split(','); let mut res = Locale::from( - try!(LanguageRange::new( - i.next().unwrap()))); // NOTE: split "" is (""), not () + LanguageRange::new( + i.next().unwrap())?); // NOTE: split "" is (""), not () for t in i { if let Some(caps) = LOCALE_ELEMENT_REGEX.captures(t) { - let tag = try!(LanguageRange::new( - try!(caps.name("tag").map(|m| m.as_str()).ok_or(Error::NotWellFormed)))); + let tag = LanguageRange::new( + caps.name("tag").map(|m| m.as_str()).ok_or(Error::NotWellFormed)?)?; match caps.name("category").map(|m| m.as_str()) { Some(cat) => res.add_category(cat.to_ascii_lowercase().as_ref(), &tag), None => res.add(&tag), diff --git a/src/macos.rs b/src/macos.rs index 5da31b8..ad42c1a 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -11,7 +11,7 @@ pub fn system_locale() -> Option { let nslocale = class!(NSLocale); let current_locale: *mut Object = msg_send![nslocale, currentLocale]; let locale_identifier: *const NSString = msg_send![current_locale, localeIdentifier]; - locale_identifier.as_ref().unwrap() + locale_identifier.as_ref() }; - Some(Locale::from(LanguageRange::from_unix(locale_identifier.as_str()).unwrap())) + Some(Locale::from(LanguageRange::from_unix(locale_identifier?.as_str()).ok()?)) }