Add Debug impls

This commit is contained in:
Ben S
2016-01-28 17:15:27 +00:00
parent 54d53c82b2
commit 32d340e128
+16 -4
View File
@@ -30,6 +30,7 @@
//! functions.
use std::ffi::{CStr, CString};
use std::fmt;
use std::ptr::read;
use std::sync::Arc;
@@ -41,8 +42,6 @@ use libc::{c_char, time_t};
#[cfg(target_os = "linux")]
use libc::c_char;
//use os::*;
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly"))]
#[repr(C)]
@@ -93,6 +92,7 @@ extern {
fn getegid() -> gid_t;
}
/// Information about a particular user.
#[derive(Clone)]
pub struct User {
@@ -137,6 +137,13 @@ impl User {
}
}
impl fmt::Debug for User {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "User({}, {})", self.uid(), self.name())
}
}
/// Information about a particular group.
#[derive(Clone)]
pub struct Group {
@@ -174,6 +181,13 @@ impl Group {
}
}
impl fmt::Debug for Group {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(f, "Group({}, {})", self.gid(), self.name())
}
}
/// Reads data from a `*char` field in `c_passwd` or `g_group` into a UTF-8
/// `String` for use in a user or group value.
///
@@ -352,8 +366,6 @@ pub fn get_effective_groupname() -> Option<String> {
}
/// OS-specific extensions to users and groups.
///
/// Every OS has a different idea of what data a user or a group comes with.