Skip to content

Commit c9d0d54

Browse files
committed
style: Make clippy happy
1 parent cf87ca6 commit c9d0d54

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

crates/toml_edit/src/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Index for str {
3838
Item::Value(ref v) => v
3939
.as_inline_table()
4040
.and_then(|t| t.items.get(self))
41-
.and_then(|value| if !value.is_none() { Some(value) } else { None }),
41+
.filter(|value| !value.is_none()),
4242
_ => None,
4343
}
4444
}

crates/toml_edit/src/table.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,16 +358,12 @@ impl Table {
358358

359359
/// Returns an optional reference to an item given the key.
360360
pub fn get<'a>(&'a self, key: &str) -> Option<&'a Item> {
361-
self.items
362-
.get(key)
363-
.and_then(|value| if !value.is_none() { Some(value) } else { None })
361+
self.items.get(key).filter(|value| !value.is_none())
364362
}
365363

366364
/// Returns an optional mutable reference to an item given the key.
367365
pub fn get_mut<'a>(&'a mut self, key: &str) -> Option<&'a mut Item> {
368-
self.items
369-
.get_mut(key)
370-
.and_then(|value| if !value.is_none() { Some(value) } else { None })
366+
self.items.get_mut(key).filter(|value| !value.is_none())
371367
}
372368

373369
/// Return references to the key-value pair stored for key, if it is present, else None.

0 commit comments

Comments
 (0)