diff --git a/time-macros/src/format_description/format_item.rs b/time-macros/src/format_description/format_item.rs index b5c6d05ff..ea36caee0 100644 --- a/time-macros/src/format_description/format_item.rs +++ b/time-macros/src/format_description/format_item.rs @@ -102,14 +102,9 @@ impl From> for crate::format_description::public::OwnedFormatItem { impl<'a> From]>> for crate::format_description::public::OwnedFormatItem { fn from(items: Box<[Item<'a>]>) -> Self { let items = items.into_vec(); - if items.len() == 1 { - if let Ok([item]) = <[_; 1]>::try_from(items) { - item.into() - } else { - bug!("the length was just checked to be 1") - } - } else { - Self::Compound(items.into_iter().map(Self::from).collect()) + match <[_; 1]>::try_from(items) { + Ok([item]) => item.into(), + Err(vec) => Self::Compound(vec.into_iter().map(Into::into).collect()), } } } diff --git a/time/src/format_description/parse/format_item.rs b/time/src/format_description/parse/format_item.rs index 3199b079b..2e1ee6a74 100644 --- a/time/src/format_description/parse/format_item.rs +++ b/time/src/format_description/parse/format_item.rs @@ -149,14 +149,9 @@ impl From> for crate::format_description::OwnedFormatItem { impl<'a> From]>> for crate::format_description::OwnedFormatItem { fn from(items: Box<[Item<'a>]>) -> Self { let items = items.into_vec(); - if items.len() == 1 { - if let Ok([item]) = <[_; 1]>::try_from(items) { - item.into() - } else { - bug!("the length was just checked to be 1") - } - } else { - Self::Compound(items.into_iter().map(Self::from).collect()) + match <[_; 1]>::try_from(items) { + Ok([item]) => item.into(), + Err(vec) => Self::Compound(vec.into_iter().map(Into::into).collect()), } } }