Skip to content

Commit

Permalink
Add Default impl for OSUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
ogham committed Jan 16, 2016
1 parent 052cf24 commit 28d4d68
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ struct BiMap<K, V> {
backward: RefCell< HashMap<Arc<String>, Option<K>> >,
}

impl OSUsers {
/// Create a new empty OS Users object.
pub fn empty_cache() -> OSUsers {
// Default has to be impl'd manually here, because there's no
// Default impl on User or Group, even though those types aren't
// needed to produce a default instance of any HashMaps...

impl Default for OSUsers {
fn default() -> OSUsers {
OSUsers {
users: BiMap {
forward: RefCell::new(HashMap::new()),
Expand All @@ -114,6 +117,14 @@ impl OSUsers {
}
}

impl OSUsers {

/// Create a new empty cache.
pub fn empty_cache() -> OSUsers {
OSUsers::default()
}
}

impl Users for OSUsers {
fn get_user_by_uid(&self, uid: uid_t) -> Option<Arc<User>> {
let mut users_forward = self.users.forward.borrow_mut();
Expand Down

0 comments on commit 28d4d68

Please sign in to comment.