Skip to content

Commit c98044c

Browse files
ada4ammstick
authored andcommitted
chore: don't needlessly partial_cmp two &strs
As `STR_ORDER` states, `&str` implements `Ord`, and thus has access to the infallible `cmp`
1 parent bfb0d2a commit c98044c

File tree

1 file changed

+2
-7
lines changed
  • cosmic-settings/src/pages/input/keyboard

1 file changed

+2
-7
lines changed

cosmic-settings/src/pages/input/keyboard/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ static CAPS_LOCK_OPTIONS: &[(&str, &str)] = &[
5252
("Control", "caps:ctrl_modifier"),
5353
];
5454

55-
const STR_ORDER: &str = "`str` is always comparable";
56-
5755
#[derive(Clone, Debug)]
5856
pub enum Message {
5957
ExpandInputSourcePopover(Option<DefaultKey>),
@@ -360,10 +358,7 @@ impl page::Page<crate::pages::Message> for Page {
360358
(_, "custom") => cmp::Ordering::Less,
361359
// Compare everything else by description because it looks nicer (e.g. all
362360
// English grouped together)
363-
_ => a
364-
.description()
365-
.partial_cmp(b.description())
366-
.expect(STR_ORDER),
361+
_ => a.description().cmp(b.description()),
367362
}
368363
});
369364

@@ -387,7 +382,7 @@ impl page::Page<crate::pages::Message> for Page {
387382
}) {
388383
let mut variants: Vec<_> = variants.collect();
389384
variants.sort_unstable_by(|(_, _, desc_a, _), (_, _, desc_b, _)| {
390-
desc_a.partial_cmp(desc_b).expect(STR_ORDER)
385+
desc_a.cmp(desc_b)
391386
});
392387

393388
for (layout_name, name, description, source) in variants {

0 commit comments

Comments
 (0)