From 65322752873bfef4f3630e72038def9f6d0bc811 Mon Sep 17 00:00:00 2001 From: oleg Date: Sat, 14 May 2022 09:39:09 +0300 Subject: [PATCH 1/4] fix unwrap issue for mac --- .idea/workspace.xml | 51 +++++++++++++++++++++++++++++++++++++++++++++ src/macos.rs | 4 ++-- 2 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 .idea/workspace.xml 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/macos.rs b/src/macos.rs index 5da31b8..88354bb 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())?)) } From eb64c21ee7c41c04425b8c8fc288646c84a11aaf Mon Sep 17 00:00:00 2001 From: oleg Date: Sat, 14 May 2022 09:40:33 +0300 Subject: [PATCH 2/4] fix unwrap issue for mac --- src/macos.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/macos.rs b/src/macos.rs index 88354bb..ad42c1a 100644 --- a/src/macos.rs +++ b/src/macos.rs @@ -13,5 +13,5 @@ pub fn system_locale() -> Option { let locale_identifier: *const NSString = msg_send![current_locale, localeIdentifier]; locale_identifier.as_ref() }; - Some(Locale::from(LanguageRange::from_unix(locale_identifier?.as_str())?)) + Some(Locale::from(LanguageRange::from_unix(locale_identifier?.as_str()).ok()?)) } From a46992cc0fea89057febb322be816e1b4df3050d Mon Sep 17 00:00:00 2001 From: oleg Date: Sat, 14 May 2022 10:00:16 +0300 Subject: [PATCH 3/4] improve unwrap --- src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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), From 8cbab38725587601a5d2a5a6eb051b9e2ba5d43b Mon Sep 17 00:00:00 2001 From: Eir Nym <485399+eirnym@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:45:33 +0200 Subject: [PATCH 4/4] Remove unneeded files --- .idea/workspace.xml | 51 --------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 .idea/workspace.xml diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 8b7ee75..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1652507842344 - - - - \ No newline at end of file