Add safety note to library/std/src/sys/unix/fd.rs

Co-authored-by: Elichai Turkel <elichai.turkel@gmail.com>
This commit is contained in:
Michael Howell 2020-07-30 12:11:30 -07:00
parent 59abdb6a7e
commit a50811a214

View File

@ -69,6 +69,7 @@ const fn max_iov() -> usize {
impl FileDesc {
pub fn new(fd: c_int) -> FileDesc {
assert_ne!(fd, -1);
// SAFETY: we just asserted that the value is in the valid range and isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned)
unsafe { FileDesc { fd } }
}