Skip to content

Commit

Permalink
Merge pull request #3 from eirtools/unwrap
Browse files Browse the repository at this point in the history
fix unwrap issue for mac
  • Loading branch information
eirnym authored Oct 21, 2024
2 parents 5f1fea8 + 8961cc4 commit e122e97
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,12 @@ impl Locale {
pub fn new(s: &str) -> Result<Locale> {
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),
Expand Down

0 comments on commit e122e97

Please sign in to comment.