Skip to content

Commit

Permalink
Improve from_anything definition using where clause
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Salvador <[email protected]>
  • Loading branch information
otavio committed Aug 28, 2019
1 parent b3d7716 commit b361db0
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2459,11 +2459,12 @@ impl From<&libc::passwd> for User {
}

impl User {
fn from_anything(f: impl Fn(*mut libc::passwd,
*mut libc::c_char,
libc::size_t,
*mut *mut libc::passwd) -> libc::c_int)
-> Result<Option<Self>>
fn from_anything<F>(f: F) -> Result<Option<Self>>
where
F: Fn(*mut libc::passwd,
*mut libc::c_char,
libc::size_t,
*mut *mut libc::passwd) -> libc::c_int
{
let bufsize = match sysconf(SysconfVar::GETPW_R_SIZE_MAX) {
Ok(Some(n)) => n as usize,
Expand Down Expand Up @@ -2578,11 +2579,12 @@ impl Group {
ret
}

fn from_anything(f: impl Fn(*mut libc::group,
*mut libc::c_char,
libc::size_t,
*mut *mut libc::group) -> libc::c_int)
-> Result<Option<Self>>
fn from_anything<F>(f: F) -> Result<Option<Self>>
where
F: Fn(*mut libc::group,
*mut libc::c_char,
libc::size_t,
*mut *mut libc::group) -> libc::c_int
{
let bufsize = match sysconf(SysconfVar::GETGR_R_SIZE_MAX) {
Ok(Some(n)) => n as usize,
Expand Down

0 comments on commit b361db0

Please sign in to comment.