diff options
Diffstat (limited to 'src/permissions/permissions_unix.rs')
-rw-r--r-- | src/permissions/permissions_unix.rs | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/permissions/permissions_unix.rs b/src/permissions/permissions_unix.rs index bae53ae..90daca4 100644 --- a/src/permissions/permissions_unix.rs +++ b/src/permissions/permissions_unix.rs @@ -1,5 +1,4 @@ - -use std::collections::{HashMap}; +use std::collections::HashMap; use std::sync::Mutex; #[cfg(unix)] @@ -11,12 +10,15 @@ pub fn user_name(uid: u32) -> String { static ref USERS_CACHE_MUTEX: Mutex<HashMap<u32, String>> = Mutex::new(HashMap::new()); } let mut users_cache = USERS_CACHE_MUTEX.lock().unwrap(); - users_cache.entry(uid).or_insert_with( - || users::get_user_by_uid(uid).map_or_else( - || "????".to_string(), - |u| u.name().to_string_lossy().to_string() - ) - ).to_string() + users_cache + .entry(uid) + .or_insert_with(|| { + users::get_user_by_uid(uid).map_or_else( + || "????".to_string(), + |u| u.name().to_string_lossy().to_string(), + ) + }) + .to_string() } #[cfg(unix)] @@ -25,16 +27,17 @@ pub fn group_name(gid: u32) -> String { static ref USERS_CACHE_MUTEX: Mutex<HashMap<u32, String>> = Mutex::new(HashMap::new()); } let mut groups_cache = USERS_CACHE_MUTEX.lock().unwrap(); - groups_cache.entry(gid).or_insert_with( - || users::get_group_by_gid(gid).map_or_else( - || "????".to_string(), - |u| u.name().to_string_lossy().to_string() - ) - ).to_string() + groups_cache + .entry(gid) + .or_insert_with(|| { + users::get_group_by_gid(gid).map_or_else( + || "????".to_string(), + |u| u.name().to_string_lossy().to_string(), + ) + }) + .to_string() } - - /* mettre directement les string en cache |