51
51
#![ deny( missing_copy_implementations) ]
52
52
#![ deny( missing_debug_implementations) ]
53
53
#![ warn( missing_docs) ]
54
-
55
54
#![ cfg_attr( docsrs, feature( doc_cfg) ) ]
56
55
57
56
// Re-exported external crates
58
57
pub use libc;
59
58
60
59
// Private internal modules
61
- #[ macro_use] mod macros;
60
+ #[ macro_use]
61
+ mod macros;
62
62
63
63
// Public crates
64
64
#[ cfg( not( target_os = "redox" ) ) ]
@@ -99,25 +99,24 @@ feature! {
99
99
#[ deny( missing_docs) ]
100
100
pub mod net;
101
101
}
102
- #[ cfg( any( target_os = "android" ,
103
- target_os = "linux" ) ) ]
102
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
104
103
feature ! {
105
104
#![ feature = "kmod" ]
106
105
#[ allow( missing_docs) ]
107
106
pub mod kmod;
108
107
}
109
- #[ cfg( any( target_os = "android" ,
110
- target_os = "freebsd" ,
111
- target_os = "linux" ) ) ]
108
+ #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux" ) ) ]
112
109
feature ! {
113
110
#![ feature = "mount" ]
114
111
pub mod mount;
115
112
}
116
- #[ cfg( any( target_os = "dragonfly" ,
117
- target_os = "freebsd" ,
118
- target_os = "fushsia" ,
119
- target_os = "linux" ,
120
- target_os = "netbsd" ) ) ]
113
+ #[ cfg( any(
114
+ target_os = "dragonfly" ,
115
+ target_os = "freebsd" ,
116
+ target_os = "fushsia" ,
117
+ target_os = "linux" ,
118
+ target_os = "netbsd"
119
+ ) ) ]
121
120
feature ! {
122
121
#![ feature = "mqueue" ]
123
122
#[ allow( missing_docs) ]
@@ -145,8 +144,7 @@ feature! {
145
144
}
146
145
// This can be implemented for other platforms as soon as libc
147
146
// provides bindings for them.
148
- #[ cfg( all( target_os = "linux" ,
149
- any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
147
+ #[ cfg( all( target_os = "linux" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
150
148
feature ! {
151
149
#![ feature = "ucontext" ]
152
150
#[ allow( missing_docs) ]
@@ -163,10 +161,10 @@ pub mod unistd;
163
161
164
162
use libc:: PATH_MAX ;
165
163
166
- use std:: result;
167
164
use std:: ffi:: { CStr , OsStr } ;
168
165
use std:: os:: unix:: ffi:: OsStrExt ;
169
166
use std:: path:: { Path , PathBuf } ;
167
+ use std:: result;
170
168
171
169
use errno:: Errno ;
172
170
@@ -197,7 +195,8 @@ pub trait NixPath {
197
195
///
198
196
/// Mostly used internally by Nix.
199
197
fn with_nix_path < T , F > ( & self , f : F ) -> Result < T >
200
- where F : FnOnce ( & CStr ) -> T ;
198
+ where
199
+ F : FnOnce ( & CStr ) -> T ;
201
200
}
202
201
203
202
impl NixPath for str {
@@ -210,9 +209,11 @@ impl NixPath for str {
210
209
}
211
210
212
211
fn with_nix_path < T , F > ( & self , f : F ) -> Result < T >
213
- where F : FnOnce ( & CStr ) -> T {
214
- OsStr :: new ( self ) . with_nix_path ( f)
215
- }
212
+ where
213
+ F : FnOnce ( & CStr ) -> T ,
214
+ {
215
+ OsStr :: new ( self ) . with_nix_path ( f)
216
+ }
216
217
}
217
218
218
219
impl NixPath for OsStr {
@@ -225,9 +226,11 @@ impl NixPath for OsStr {
225
226
}
226
227
227
228
fn with_nix_path < T , F > ( & self , f : F ) -> Result < T >
228
- where F : FnOnce ( & CStr ) -> T {
229
- self . as_bytes ( ) . with_nix_path ( f)
230
- }
229
+ where
230
+ F : FnOnce ( & CStr ) -> T ,
231
+ {
232
+ self . as_bytes ( ) . with_nix_path ( f)
233
+ }
231
234
}
232
235
233
236
impl NixPath for CStr {
@@ -240,10 +243,12 @@ impl NixPath for CStr {
240
243
}
241
244
242
245
fn with_nix_path < T , F > ( & self , f : F ) -> Result < T >
243
- where F : FnOnce ( & CStr ) -> T {
246
+ where
247
+ F : FnOnce ( & CStr ) -> T ,
248
+ {
244
249
// Equivalence with the [u8] impl.
245
250
if self . len ( ) >= PATH_MAX as usize {
246
- return Err ( Errno :: ENAMETOOLONG )
251
+ return Err ( Errno :: ENAMETOOLONG ) ;
247
252
}
248
253
249
254
Ok ( f ( self ) )
@@ -260,11 +265,13 @@ impl NixPath for [u8] {
260
265
}
261
266
262
267
fn with_nix_path < T , F > ( & self , f : F ) -> Result < T >
263
- where F : FnOnce ( & CStr ) -> T {
268
+ where
269
+ F : FnOnce ( & CStr ) -> T ,
270
+ {
264
271
let mut buf = [ 0u8 ; PATH_MAX as usize ] ;
265
272
266
273
if self . len ( ) >= PATH_MAX as usize {
267
- return Err ( Errno :: ENAMETOOLONG )
274
+ return Err ( Errno :: ENAMETOOLONG ) ;
268
275
}
269
276
270
277
buf[ ..self . len ( ) ] . copy_from_slice ( self ) ;
@@ -284,7 +291,10 @@ impl NixPath for Path {
284
291
NixPath :: len ( self . as_os_str ( ) )
285
292
}
286
293
287
- fn with_nix_path < T , F > ( & self , f : F ) -> Result < T > where F : FnOnce ( & CStr ) -> T {
294
+ fn with_nix_path < T , F > ( & self , f : F ) -> Result < T >
295
+ where
296
+ F : FnOnce ( & CStr ) -> T ,
297
+ {
288
298
self . as_os_str ( ) . with_nix_path ( f)
289
299
}
290
300
}
@@ -298,7 +308,10 @@ impl NixPath for PathBuf {
298
308
NixPath :: len ( self . as_os_str ( ) )
299
309
}
300
310
301
- fn with_nix_path < T , F > ( & self , f : F ) -> Result < T > where F : FnOnce ( & CStr ) -> T {
311
+ fn with_nix_path < T , F > ( & self , f : F ) -> Result < T >
312
+ where
313
+ F : FnOnce ( & CStr ) -> T ,
314
+ {
302
315
self . as_os_str ( ) . with_nix_path ( f)
303
316
}
304
317
}
0 commit comments