Skip to content

Commit

Permalink
Eliminate unreachable branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpratt committed Mar 30, 2024
1 parent 06a096d commit f04a28f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
11 changes: 3 additions & 8 deletions time-macros/src/format_description/format_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,9 @@ impl From<Item<'_>> for crate::format_description::public::OwnedFormatItem {
impl<'a> From<Box<[Item<'a>]>> 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()),
}
}
}
Expand Down
11 changes: 3 additions & 8 deletions time/src/format_description/parse/format_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,9 @@ impl From<Item<'_>> for crate::format_description::OwnedFormatItem {
impl<'a> From<Box<[Item<'a>]>> 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()),
}
}
}
Expand Down

0 comments on commit f04a28f

Please sign in to comment.