Skip to content

Commit

Permalink
src: Fix 'contains_key' clippy lints
Browse files Browse the repository at this point in the history
```
warning: unnecessary use of `get(k).is_some()`
   --> src/filetree.rs:187:34
    |
187 |                 if self.children.get(k).is_some() {
    |                                  ^^^^^^^^^^^^^^^^ help: replace it with: `contains_key(k)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    = note: `#[warn(clippy::unnecessary_get_then_check)]` on by default
```
  • Loading branch information
travier committed Dec 5, 2024
1 parent 822640c commit 942aeb8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bootupd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ pub(crate) fn adopt_and_update(name: &str) -> Result<ContentMetadata> {
let sysroot = openat::Dir::open("/")?;
let mut state = SavedState::load_from_disk("/")?.unwrap_or_default();
let component = component::new_from_name(name)?;
if state.installed.get(name).is_some() {
if state.installed.contains_key(name) {
anyhow::bail!("Component {} is already installed", name);
};

Expand Down
2 changes: 1 addition & 1 deletion src/filetree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl FileTree {
}
if check_additions {
for k in updated.children.keys() {
if self.children.get(k).is_some() {
if self.children.contains_key(k) {
continue;
}
additions.insert(k.clone());
Expand Down

0 comments on commit 942aeb8

Please sign in to comment.