diff --git a/src/cmd/get.rs b/src/cmd/get.rs index 8687645..2887c77 100644 --- a/src/cmd/get.rs +++ b/src/cmd/get.rs @@ -9,9 +9,9 @@ use crate::{ use std::{collections::HashMap, io::Write, path::PathBuf}; #[derive(Serialize)] -struct FileXattrs<'a> { +struct FileXattrs<'a, 'b> { path: String, - xattrs: HashMap<&'a Xattr, Value>, + xattrs: HashMap<&'a Xattr, &'b Value>, } pub fn get( @@ -44,22 +44,13 @@ pub fn get( fields.clone() }; if *json { - let mut xattrs: HashMap<&Xattr, Value> = HashMap::with_capacity(projected_fields.len()); + let mut xattrs: HashMap<&Xattr, &Value> = + HashMap::with_capacity(projected_fields.len()); for field in projected_fields.iter() { - let field_osstring = field.to_osstring(); - if let Some(value) = xattr::get(&path, field_osstring).unwrap_or_else(|e| { - panic!( - "Could not get xattr {} from {}: {}", - field, - path.display(), - e - ); - }) { - let value = Value::from(value.as_slice()); + let value = &all_field_values[field]; - xattrs.insert(field, value); - } + xattrs.insert(field, value); } if !xattrs.is_empty() {