Skip to content

Commit f32efad

Browse files
Merge pull request #175 from SamuelMarks/rustfmt
[*.rs] rustfmt
2 parents 81cb8cf + 620be63 commit f32efad

File tree

5 files changed

+33
-16
lines changed

5 files changed

+33
-16
lines changed

src/core_lazy.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ impl<T: Sync> Lazy<T> {
1616

1717
#[inline(always)]
1818
pub fn get<F>(&'static self, builder: F) -> &T
19-
where F: FnOnce() -> T
19+
where
20+
F: FnOnce() -> T,
2021
{
2122
self.0.call_once(builder)
2223
}
@@ -27,5 +28,5 @@ impl<T: Sync> Lazy<T> {
2728
macro_rules! __lazy_static_create {
2829
($NAME:ident, $T:ty) => {
2930
static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT;
30-
}
31+
};
3132
}

src/inline_lazy.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
extern crate core;
99
extern crate std;
1010

11-
use self::std::prelude::v1::*;
1211
use self::std::cell::Cell;
1312
use self::std::hint::unreachable_unchecked;
13+
use self::std::prelude::v1::*;
1414
use self::std::sync::Once;
1515
#[allow(deprecated)]
1616
pub use self::std::sync::ONCE_INIT;
@@ -37,10 +37,13 @@ impl<T: Sync> Lazy<T> {
3737
match *self.0.as_ptr() {
3838
Some(ref x) => x,
3939
None => {
40-
debug_assert!(false, "attempted to derefence an uninitialized lazy static. This is a bug");
40+
debug_assert!(
41+
false,
42+
"attempted to derefence an uninitialized lazy static. This is a bug"
43+
);
4144

4245
unreachable_unchecked()
43-
},
46+
}
4447
}
4548
}
4649
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ This crate provides one cargo feature:
9898
#![no_std]
9999

100100
#[cfg(not(feature = "spin_no_std"))]
101-
#[path="inline_lazy.rs"]
101+
#[path = "inline_lazy.rs"]
102102
#[doc(hidden)]
103103
pub mod lazy;
104104

@@ -110,7 +110,7 @@ extern crate doc_comment;
110110
doctest!("../README.md");
111111

112112
#[cfg(feature = "spin_no_std")]
113-
#[path="core_lazy.rs"]
113+
#[path = "core_lazy.rs"]
114114
#[doc(hidden)]
115115
pub mod lazy;
116116

tests/no_std.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#![cfg(feature="spin_no_std")]
2-
1+
#![cfg(feature = "spin_no_std")]
32
#![no_std]
43

54
#[macro_use]

tests/test.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ fn test_meta() {
6969
assert!(&STRING as *const _ != &copy_of_string as *const _);
7070

7171
// this would not compile if STRING were not marked #[derive(Debug)]
72-
assert_eq!(format!("{:?}", STRING), "STRING { __private_field: () }".to_string());
72+
assert_eq!(
73+
format!("{:?}", STRING),
74+
"STRING { __private_field: () }".to_string()
75+
);
7376
}
7477

7578
mod visibility {
@@ -111,10 +114,18 @@ struct Once(X);
111114
const ONCE_INIT: Once = Once(X);
112115
static DATA: X = X;
113116
static ONCE: X = X;
114-
fn require_sync() -> X { X }
115-
fn transmute() -> X { X }
116-
fn __static_ref_initialize() -> X { X }
117-
fn test(_: Vec<X>) -> X { X }
117+
fn require_sync() -> X {
118+
X
119+
}
120+
fn transmute() -> X {
121+
X
122+
}
123+
fn __static_ref_initialize() -> X {
124+
X
125+
}
126+
fn test(_: Vec<X>) -> X {
127+
X
128+
}
118129

119130
// All these names should not be shadowed
120131
lazy_static! {
@@ -133,9 +144,9 @@ fn item_name_shadowing() {
133144
}
134145

135146
use std::sync::atomic::AtomicBool;
147+
use std::sync::atomic::Ordering::SeqCst;
136148
#[allow(deprecated)]
137149
use std::sync::atomic::ATOMIC_BOOL_INIT;
138-
use std::sync::atomic::Ordering::SeqCst;
139150

140151
#[allow(deprecated)]
141152
static PRE_INIT_FLAG: AtomicBool = ATOMIC_BOOL_INIT;
@@ -155,7 +166,10 @@ fn pre_init() {
155166
}
156167

157168
lazy_static! {
158-
static ref LIFETIME_NAME: for<'a> fn(&'a u8) = { fn f(_: &u8) {} f };
169+
static ref LIFETIME_NAME: for<'a> fn(&'a u8) = {
170+
fn f(_: &u8) {}
171+
f
172+
};
159173
}
160174

161175
#[test]

0 commit comments

Comments
 (0)