Skip to content

Commit 5c46aca

Browse files
committed
document the cvt methods
1 parent aabbf84 commit 5c46aca

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • library/std/src/sys/pal/unix

‎library/std/src/sys/pal/unix/mod.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,13 @@ macro_rules! impl_is_minus_one {
307307

308308
impl_is_minus_one!{i8i16i32i64isize}
309309

310+
/// Convert native return values to Result using the *-1 means error is in `errno`* convention.
311+
/// Non-error values are `Ok`-wrapped.
310312
pubfncvt<T:IsMinusOne>(t:T) -> crate::io::Result<T>{
311313
if t.is_minus_one(){Err(crate::io::Error::last_os_error())}else{Ok(t)}
312314
}
313315

316+
/// `-1` → look at `errno` → retry on `EINTR`. Otherwise `Ok()`-wrap the closure return value.
314317
pubfncvt_r<T,F>(mutf:F) -> crate::io::Result<T>
315318
where
316319
T:IsMinusOne,
@@ -325,6 +328,7 @@ where
325328
}
326329

327330
#[allow(dead_code)]// Not used on all platforms.
331+
/// Zero means `Ok()`, all other values are treated as raw OS errors. Does not look at `errno`.
328332
pubfncvt_nz(error: libc::c_int) -> crate::io::Result<()>{
329333
if error == 0{Ok(())}else{Err(crate::io::Error::from_raw_os_error(error))}
330334
}

0 commit comments

Comments
 (0)