mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 01:05:01 +02:00
Match cleanup (#2294)
* Delete unnecessary match * Use `unwrap_or_else()` * Whitespace was trim on file save * Use `map_or_else()` * Use a default to group all match arms with same output * Clippy made me do it
This commit is contained in:
@ -237,10 +237,7 @@ pub fn group(
|
||||
crate::utils::data::group(&values, &Some(block), &name)
|
||||
}
|
||||
Grouper::ByColumn(None) => {
|
||||
let block = Box::new(move |_, row: &Value| match as_string(row) {
|
||||
Ok(group_key) => Ok(group_key),
|
||||
Err(reason) => Err(reason),
|
||||
});
|
||||
let block = Box::new(move |_, row: &Value| as_string(row));
|
||||
|
||||
crate::utils::data::group(&values, &Some(block), &name)
|
||||
}
|
||||
|
@ -54,14 +54,10 @@ impl DictionaryExt for Dictionary {
|
||||
}
|
||||
|
||||
fn get_mut_data_by_key(&mut self, name: &str) -> Option<&mut Value> {
|
||||
match self
|
||||
.entries
|
||||
self.entries
|
||||
.iter_mut()
|
||||
.find(|(desc_name, _)| *desc_name == name)
|
||||
{
|
||||
Some((_, v)) => Some(v),
|
||||
None => None,
|
||||
}
|
||||
.map_or_else(|| None, |x| Some(x.1))
|
||||
}
|
||||
|
||||
fn insert_data_at_key(&mut self, name: &str, value: Value) {
|
||||
|
Reference in New Issue
Block a user