Skip to content

Commit

Permalink
More thorough aux key subtag check (#4201)
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc authored Oct 21, 2023
1 parent e0849fd commit 1299c57
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions components/datetime/src/provider/neo/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,23 @@ mod subtag_consts {
}

fn single_aux_subtag<M: KeyedDataMarker>(locale: &DataLocale) -> Result<Subtag, DataError> {
#[allow(clippy::unwrap_used)]
locale
.get_aux()
.and_then(|aux| aux.iter().next())
.ok_or_else(|| {
DataError::custom("Expected aux key")
.with_key(M::KEY)
.with_debug_context(locale)
})
let Some(aux) = locale.get_aux() else {
return Err(DataError::custom("Expected a single aux key")
.with_key(M::KEY)
.with_debug_context(locale));
};
let mut iter = aux.iter();
let Some(subtag) = iter.next() else {
return Err(DataError::custom("Expected a single aux key")
.with_key(M::KEY)
.with_debug_context(locale));
};
if iter.next().is_some() {
return Err(DataError::custom("Expected a single aux key")
.with_key(M::KEY)
.with_debug_context(locale));
}
Ok(subtag)
}

fn month_symbols_map_project_cloned<M, P>(
Expand Down

0 comments on commit 1299c57

Please sign in to comment.