@@ -2463,7 +2463,7 @@ impl User {
2463
2463
* mut libc:: c_char ,
2464
2464
libc:: size_t ,
2465
2465
* mut * mut libc:: passwd ) -> libc:: c_int )
2466
- -> Option < Result < Self > >
2466
+ -> Result < Option < Self > >
2467
2467
{
2468
2468
let bufsize = match sysconf ( SysconfVar :: GETPW_R_SIZE_MAX ) {
2469
2469
Ok ( Some ( n) ) => n as usize ,
@@ -2482,18 +2482,18 @@ impl User {
2482
2482
2483
2483
if error == 0 {
2484
2484
if res. is_null ( ) {
2485
- return None ;
2485
+ return Ok ( None ) ;
2486
2486
} else {
2487
2487
let pwd = unsafe { pwd. assume_init ( ) } ;
2488
- return Some ( Ok ( User :: from ( & pwd) ) ) ;
2488
+ return Ok ( Some ( User :: from ( & pwd) ) ) ;
2489
2489
}
2490
2490
} else if Errno :: last ( ) == Errno :: ERANGE {
2491
2491
// Trigger the internal buffer resizing logic of `Vec` by requiring
2492
2492
// more space than the current capacity.
2493
2493
unsafe { cbuf. set_len ( cbuf. capacity ( ) ) ; }
2494
2494
cbuf. reserve ( 1 ) ;
2495
2495
} else {
2496
- return Some ( Err ( Error :: Sys ( Errno :: last ( ) ) ) ) ;
2496
+ return Err ( Error :: Sys ( Errno :: last ( ) ) ) ;
2497
2497
}
2498
2498
}
2499
2499
}
@@ -2507,11 +2507,11 @@ impl User {
2507
2507
///
2508
2508
/// ```
2509
2509
/// use nix::unistd::{Uid, User};
2510
- /// // Returns an Option< Result<User>>, thus the double unwrap.
2510
+ /// // Returns an Result<Option <User>>, thus the double unwrap.
2511
2511
/// let res = User::from_uid(Uid::from_raw(0)).unwrap().unwrap();
2512
2512
/// assert!(res.name == "root");
2513
2513
/// ```
2514
- pub fn from_uid ( uid : Uid ) -> Option < Result < Self > > {
2514
+ pub fn from_uid ( uid : Uid ) -> Result < Option < Self > > {
2515
2515
User :: from_anything ( |pwd, cbuf, cap, res| {
2516
2516
unsafe { libc:: getpwuid_r ( uid. 0 , pwd, cbuf, cap, res) }
2517
2517
} )
@@ -2526,11 +2526,11 @@ impl User {
2526
2526
///
2527
2527
/// ```
2528
2528
/// use nix::unistd::User;
2529
- /// // Returns an Option< Result<User>>, thus the double unwrap.
2529
+ /// // Returns an Result<Option <User>>, thus the double unwrap.
2530
2530
/// let res = User::from_name("root").unwrap().unwrap();
2531
2531
/// assert!(res.name == "root");
2532
2532
/// ```
2533
- pub fn from_name ( name : & str ) -> Option < Result < Self > > {
2533
+ pub fn from_name ( name : & str ) -> Result < Option < Self > > {
2534
2534
let name = CString :: new ( name) . unwrap ( ) ;
2535
2535
User :: from_anything ( |pwd, cbuf, cap, res| {
2536
2536
unsafe { libc:: getpwnam_r ( name. as_ptr ( ) , pwd, cbuf, cap, res) }
@@ -2582,7 +2582,7 @@ impl Group {
2582
2582
* mut libc:: c_char ,
2583
2583
libc:: size_t ,
2584
2584
* mut * mut libc:: group ) -> libc:: c_int )
2585
- -> Option < Result < Self > >
2585
+ -> Result < Option < Self > >
2586
2586
{
2587
2587
let bufsize = match sysconf ( SysconfVar :: GETGR_R_SIZE_MAX ) {
2588
2588
Ok ( Some ( n) ) => n as usize ,
@@ -2601,18 +2601,18 @@ impl Group {
2601
2601
2602
2602
if error == 0 {
2603
2603
if res. is_null ( ) {
2604
- return None ;
2604
+ return Ok ( None ) ;
2605
2605
} else {
2606
2606
let grp = unsafe { grp. assume_init ( ) } ;
2607
- return Some ( Ok ( Group :: from ( & grp) ) ) ;
2607
+ return Ok ( Some ( Group :: from ( & grp) ) ) ;
2608
2608
}
2609
2609
} else if Errno :: last ( ) == Errno :: ERANGE {
2610
2610
// Trigger the internal buffer resizing logic of `Vec` by requiring
2611
2611
// more space than the current capacity.
2612
2612
unsafe { cbuf. set_len ( cbuf. capacity ( ) ) ; }
2613
2613
cbuf. reserve ( 1 ) ;
2614
2614
} else {
2615
- return Some ( Err ( Error :: Sys ( Errno :: last ( ) ) ) ) ;
2615
+ return Err ( Error :: Sys ( Errno :: last ( ) ) ) ;
2616
2616
}
2617
2617
}
2618
2618
}
@@ -2628,11 +2628,11 @@ impl Group {
2628
2628
#[ cfg_attr( not( target_os = "linux" ) , doc = " ```no_run" ) ]
2629
2629
#[ cfg_attr( target_os = "linux" , doc = " ```" ) ]
2630
2630
/// use nix::unistd::{Gid, Group};
2631
- /// // Returns an Option< Result<Group>>, thus the double unwrap.
2631
+ /// // Returns an Result<Option <Group>>, thus the double unwrap.
2632
2632
/// let res = Group::from_gid(Gid::from_raw(0)).unwrap().unwrap();
2633
2633
/// assert!(res.name == "root");
2634
2634
/// ```
2635
- pub fn from_gid ( gid : Gid ) -> Option < Result < Self > > {
2635
+ pub fn from_gid ( gid : Gid ) -> Result < Option < Self > > {
2636
2636
Group :: from_anything ( |grp, cbuf, cap, res| {
2637
2637
unsafe { libc:: getgrgid_r ( gid. 0 , grp, cbuf, cap, res) }
2638
2638
} )
@@ -2649,11 +2649,11 @@ impl Group {
2649
2649
#[ cfg_attr( not( target_os = "linux" ) , doc = " ```no_run" ) ]
2650
2650
#[ cfg_attr( target_os = "linux" , doc = " ```" ) ]
2651
2651
/// use nix::unistd::Group;
2652
- /// // Returns an Option< Result<Group>>, thus the double unwrap.
2652
+ /// // Returns an Result<Option <Group>>, thus the double unwrap.
2653
2653
/// let res = Group::from_name("root").unwrap().unwrap();
2654
2654
/// assert!(res.name == "root");
2655
2655
/// ```
2656
- pub fn from_name ( name : & str ) -> Option < Result < Self > > {
2656
+ pub fn from_name ( name : & str ) -> Result < Option < Self > > {
2657
2657
let name = CString :: new ( name) . unwrap ( ) ;
2658
2658
Group :: from_anything ( |grp, cbuf, cap, res| {
2659
2659
unsafe { libc:: getgrnam_r ( name. as_ptr ( ) , grp, cbuf, cap, res) }
0 commit comments