Skip to content

Commit 067c1a4

Browse files
committed
Run rustfmt on lib.rs and ignore .idea
Signed-off-by: Alex Saveau <[email protected]>
1 parent 2143ffe commit 067c1a4

File tree

2 files changed

+42
-28
lines changed

2 files changed

+42
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
syntax: glob
22
Cargo.lock
33
target
4+
.idea
45
*.diff
56
*.rej
67
*.orig

src/lib.rs

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@
5151
#![deny(missing_copy_implementations)]
5252
#![deny(missing_debug_implementations)]
5353
#![warn(missing_docs)]
54-
5554
#![cfg_attr(docsrs, feature(doc_cfg))]
5655

5756
// Re-exported external crates
5857
pub use libc;
5958

6059
// Private internal modules
61-
#[macro_use] mod macros;
60+
#[macro_use]
61+
mod macros;
6262

6363
// Public crates
6464
#[cfg(not(target_os = "redox"))]
@@ -99,25 +99,24 @@ feature! {
9999
#[deny(missing_docs)]
100100
pub mod net;
101101
}
102-
#[cfg(any(target_os = "android",
103-
target_os = "linux"))]
102+
#[cfg(any(target_os = "android", target_os = "linux"))]
104103
feature! {
105104
#![feature = "kmod"]
106105
#[allow(missing_docs)]
107106
pub mod kmod;
108107
}
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"))]
112109
feature! {
113110
#![feature = "mount"]
114111
pub mod mount;
115112
}
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+
))]
121120
feature! {
122121
#![feature = "mqueue"]
123122
#[allow(missing_docs)]
@@ -145,8 +144,7 @@ feature! {
145144
}
146145
// This can be implemented for other platforms as soon as libc
147146
// 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")))]
150148
feature! {
151149
#![feature = "ucontext"]
152150
#[allow(missing_docs)]
@@ -163,10 +161,10 @@ pub mod unistd;
163161

164162
use libc::PATH_MAX;
165163

166-
use std::result;
167164
use std::ffi::{CStr, OsStr};
168165
use std::os::unix::ffi::OsStrExt;
169166
use std::path::{Path, PathBuf};
167+
use std::result;
170168

171169
use errno::Errno;
172170

@@ -197,7 +195,8 @@ pub trait NixPath {
197195
///
198196
/// Mostly used internally by Nix.
199197
fn with_nix_path<T, F>(&self, f: F) -> Result<T>
200-
where F: FnOnce(&CStr) -> T;
198+
where
199+
F: FnOnce(&CStr) -> T;
201200
}
202201

203202
impl NixPath for str {
@@ -210,9 +209,11 @@ impl NixPath for str {
210209
}
211210

212211
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+
}
216217
}
217218

218219
impl NixPath for OsStr {
@@ -225,9 +226,11 @@ impl NixPath for OsStr {
225226
}
226227

227228
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+
}
231234
}
232235

233236
impl NixPath for CStr {
@@ -240,10 +243,12 @@ impl NixPath for CStr {
240243
}
241244

242245
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+
{
244249
// Equivalence with the [u8] impl.
245250
if self.len() >= PATH_MAX as usize {
246-
return Err(Errno::ENAMETOOLONG)
251+
return Err(Errno::ENAMETOOLONG);
247252
}
248253

249254
Ok(f(self))
@@ -260,11 +265,13 @@ impl NixPath for [u8] {
260265
}
261266

262267
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+
{
264271
let mut buf = [0u8; PATH_MAX as usize];
265272

266273
if self.len() >= PATH_MAX as usize {
267-
return Err(Errno::ENAMETOOLONG)
274+
return Err(Errno::ENAMETOOLONG);
268275
}
269276

270277
buf[..self.len()].copy_from_slice(self);
@@ -284,7 +291,10 @@ impl NixPath for Path {
284291
NixPath::len(self.as_os_str())
285292
}
286293

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+
{
288298
self.as_os_str().with_nix_path(f)
289299
}
290300
}
@@ -298,7 +308,10 @@ impl NixPath for PathBuf {
298308
NixPath::len(self.as_os_str())
299309
}
300310

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+
{
302315
self.as_os_str().with_nix_path(f)
303316
}
304317
}

0 commit comments

Comments
 (0)