@@ -32,7 +32,7 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
32
32
#[ rustc_layout_scalar_valid_range_end( 0xFF_FF_FF_FE ) ]
33
33
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
34
34
pub struct BorrowedFd < ' fd > {
35
- raw : RawFd ,
35
+ fd : RawFd ,
36
36
_phantom : PhantomData < & ' fd OwnedFd > ,
37
37
}
38
38
@@ -52,47 +52,47 @@ pub struct BorrowedFd<'fd> {
52
52
#[ rustc_layout_scalar_valid_range_end( 0xFF_FF_FF_FE ) ]
53
53
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
54
54
pub struct OwnedFd {
55
- raw : RawFd ,
55
+ fd : RawFd ,
56
56
}
57
57
58
58
impl BorrowedFd < ' _ > {
59
59
/// Return a `BorrowedFd` holding the given raw file descriptor.
60
60
///
61
61
/// # Safety
62
62
///
63
- /// The resource pointed to by `raw ` must remain open for the duration of
63
+ /// The resource pointed to by `fd ` must remain open for the duration of
64
64
/// the returned `BorrowedFd`, and it must not have the value `-1`.
65
65
#[ inline]
66
66
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
67
- pub unsafe fn borrow_raw_fd ( raw : RawFd ) -> Self {
68
- assert_ne ! ( raw , -1_i32 as RawFd ) ;
69
- unsafe { Self { raw , _phantom : PhantomData } }
67
+ pub unsafe fn borrow_raw_fd ( fd : RawFd ) -> Self {
68
+ assert_ne ! ( fd , -1_i32 as RawFd ) ;
69
+ unsafe { Self { fd , _phantom : PhantomData } }
70
70
}
71
71
}
72
72
73
73
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
74
74
impl AsRawFd for BorrowedFd < ' _ > {
75
75
#[ inline]
76
76
fn as_raw_fd ( & self ) -> RawFd {
77
- self . raw
77
+ self . fd
78
78
}
79
79
}
80
80
81
81
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
82
82
impl AsRawFd for OwnedFd {
83
83
#[ inline]
84
84
fn as_raw_fd ( & self ) -> RawFd {
85
- self . raw
85
+ self . fd
86
86
}
87
87
}
88
88
89
89
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
90
90
impl IntoRawFd for OwnedFd {
91
91
#[ inline]
92
92
fn into_raw_fd ( self ) -> RawFd {
93
- let raw = self . raw ;
93
+ let fd = self . fd ;
94
94
forget ( self ) ;
95
- raw
95
+ fd
96
96
}
97
97
}
98
98
@@ -102,13 +102,13 @@ impl FromRawFd for OwnedFd {
102
102
///
103
103
/// # Safety
104
104
///
105
- /// The resource pointed to by `raw ` must be open and suitable for assuming
105
+ /// The resource pointed to by `fd ` must be open and suitable for assuming
106
106
/// ownership.
107
107
#[ inline]
108
- unsafe fn from_raw_fd ( raw : RawFd ) -> Self {
109
- assert_ne ! ( raw , RawFd :: MAX ) ;
108
+ unsafe fn from_raw_fd ( fd : RawFd ) -> Self {
109
+ assert_ne ! ( fd , RawFd :: MAX ) ;
110
110
// 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)
111
- unsafe { Self { raw } }
111
+ unsafe { Self { fd } }
112
112
}
113
113
}
114
114
@@ -122,22 +122,22 @@ impl Drop for OwnedFd {
122
122
// the file descriptor was closed or not, and if we retried (for
123
123
// something like EINTR), we might close another valid file descriptor
124
124
// opened after we closed ours.
125
- let _ = libc:: close ( self . raw as raw:: c_int ) ;
125
+ let _ = libc:: close ( self . fd as raw:: c_int ) ;
126
126
}
127
127
}
128
128
}
129
129
130
130
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
131
131
impl fmt:: Debug for BorrowedFd < ' _ > {
132
132
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
133
- f. debug_struct ( "BorrowedFd" ) . field ( "fd" , & self . raw ) . finish ( )
133
+ f. debug_struct ( "BorrowedFd" ) . field ( "fd" , & self . fd ) . finish ( )
134
134
}
135
135
}
136
136
137
137
#[ unstable( feature = "io_safety" , issue = "87074" ) ]
138
138
impl fmt:: Debug for OwnedFd {
139
139
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
140
- f. debug_struct ( "OwnedFd" ) . field ( "fd" , & self . raw ) . finish ( )
140
+ f. debug_struct ( "OwnedFd" ) . field ( "fd" , & self . fd ) . finish ( )
141
141
}
142
142
}
143
143
0 commit comments