You've already forked rust-users
mirror of
https://github.com/uutils/rust-users.git
synced 2026-06-10 15:48:37 -07:00
Add Debug impls
This commit is contained in:
+16
-4
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user