Skip to content

Commit 079ff0d

Browse files
committed
rustfmt: function specifications
1 parent fd872b6 commit 079ff0d

File tree

16 files changed

+212
-84
lines changed

16 files changed

+212
-84
lines changed

rand_core/src/block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<R: BlockRngCore> BlockRng<R> {
133133
/// Create a new `BlockRng` from an existing RNG implementing
134134
/// `BlockRngCore`. Results will be generated on first use.
135135
#[inline]
136-
pub fn new(core: R) -> BlockRng<R>{
136+
pub fn new(core: R) -> BlockRng<R> {
137137
let results_empty = R::Results::default();
138138
BlockRng {
139139
core,
@@ -307,7 +307,7 @@ impl<R: BlockRngCore> BlockRng64<R> {
307307
/// Create a new `BlockRng` from an existing RNG implementing
308308
/// `BlockRngCore`. Results will be generated on first use.
309309
#[inline]
310-
pub fn new(core: R) -> BlockRng64<R>{
310+
pub fn new(core: R) -> BlockRng64<R> {
311311
let results_empty = R::Results::default();
312312
BlockRng64 {
313313
core,

rand_distr/src/exponential.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ mod test {
157157

158158
#[test]
159159
fn value_stability() {
160-
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>
161-
(distr: D, zero: N, expected: &[N])
162-
{
160+
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>(
161+
distr: D, zero: N, expected: &[N],
162+
) {
163163
let mut rng = crate::test::rng(223);
164164
let mut buf = [zero; 4];
165165
for x in &mut buf {

rand_distr/src/gamma.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,9 @@ mod test {
568568

569569
#[test]
570570
fn value_stability() {
571-
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>
572-
(distr: D, zero: N, expected: &[N])
573-
{
571+
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>(
572+
distr: D, zero: N, expected: &[N],
573+
) {
574574
let mut rng = crate::test::rng(223);
575575
let mut buf = [zero; 4];
576576
for x in &mut buf {

rand_distr/src/normal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ mod tests {
232232

233233
#[test]
234234
fn value_stability() {
235-
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>
236-
(distr: D, zero: N, expected: &[N])
237-
{
235+
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>(
236+
distr: D, zero: N, expected: &[N],
237+
) {
238238
let mut rng = crate::test::rng(213);
239239
let mut buf = [zero; 4];
240240
for x in &mut buf {

rand_distr/src/pareto.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ mod tests {
103103

104104
#[test]
105105
fn value_stability() {
106-
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>
107-
(distr: D, zero: N, expected: &[N])
108-
{
106+
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>(
107+
distr: D, zero: N, expected: &[N],
108+
) {
109109
let mut rng = crate::test::rng(213);
110110
let mut buf = [zero; 4];
111111
for x in &mut buf {

rand_distr/src/poisson.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ mod test {
243243

244244
#[test]
245245
fn value_stability() {
246-
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>
247-
(distr: D, zero: N, expected: &[N])
248-
{
246+
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>(
247+
distr: D, zero: N, expected: &[N],
248+
) {
249249
let mut rng = crate::test::rng(223);
250250
let mut buf = [zero; 4];
251251
for x in &mut buf {

rand_distr/src/utils.rs

Lines changed: 75 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ pub trait Float:
6464

6565
impl Float for f32 {
6666
#[inline]
67-
fn pi() -> Self { core::f32::consts::PI }
67+
fn pi() -> Self {
68+
core::f32::consts::PI
69+
}
70+
6871
#[inline]
69-
fn from(x: f64) -> Self { x as f32 }
72+
fn from(x: f64) -> Self {
73+
x as f32
74+
}
75+
7076
#[inline]
7177
fn to_u64(self) -> Option<u64> {
7278
if self >= 0. && self <= ::core::u64::MAX as f32 {
@@ -77,21 +83,40 @@ impl Float for f32 {
7783
}
7884

7985
#[inline]
80-
fn abs(self) -> Self { self.abs() }
86+
fn abs(self) -> Self {
87+
self.abs()
88+
}
89+
8190
#[inline]
82-
fn floor(self) -> Self { self.floor() }
83-
91+
fn floor(self) -> Self {
92+
self.floor()
93+
}
94+
8495
#[inline]
85-
fn exp(self) -> Self { self.exp() }
96+
fn exp(self) -> Self {
97+
self.exp()
98+
}
99+
86100
#[inline]
87-
fn ln(self) -> Self { self.ln() }
101+
fn ln(self) -> Self {
102+
self.ln()
103+
}
104+
88105
#[inline]
89-
fn sqrt(self) -> Self { self.sqrt() }
106+
fn sqrt(self) -> Self {
107+
self.sqrt()
108+
}
109+
90110
#[inline]
91-
fn powf(self, power: Self) -> Self { self.powf(power) }
92-
111+
fn powf(self, power: Self) -> Self {
112+
self.powf(power)
113+
}
114+
93115
#[inline]
94-
fn tan(self) -> Self { self.tan() }
116+
fn tan(self) -> Self {
117+
self.tan()
118+
}
119+
95120
#[inline]
96121
fn log_gamma(self) -> Self {
97122
let result = log_gamma(self.into());
@@ -103,9 +128,15 @@ impl Float for f32 {
103128

104129
impl Float for f64 {
105130
#[inline]
106-
fn pi() -> Self { core::f64::consts::PI }
131+
fn pi() -> Self {
132+
core::f64::consts::PI
133+
}
134+
107135
#[inline]
108-
fn from(x: f64) -> Self { x }
136+
fn from(x: f64) -> Self {
137+
x
138+
}
139+
109140
#[inline]
110141
fn to_u64(self) -> Option<u64> {
111142
if self >= 0. && self <= ::core::u64::MAX as f64 {
@@ -116,23 +147,44 @@ impl Float for f64 {
116147
}
117148

118149
#[inline]
119-
fn abs(self) -> Self { self.abs() }
150+
fn abs(self) -> Self {
151+
self.abs()
152+
}
153+
120154
#[inline]
121-
fn floor(self) -> Self { self.floor() }
122-
155+
fn floor(self) -> Self {
156+
self.floor()
157+
}
158+
123159
#[inline]
124-
fn exp(self) -> Self { self.exp() }
160+
fn exp(self) -> Self {
161+
self.exp()
162+
}
163+
125164
#[inline]
126-
fn ln(self) -> Self { self.ln() }
165+
fn ln(self) -> Self {
166+
self.ln()
167+
}
168+
127169
#[inline]
128-
fn sqrt(self) -> Self { self.sqrt() }
170+
fn sqrt(self) -> Self {
171+
self.sqrt()
172+
}
173+
129174
#[inline]
130-
fn powf(self, power: Self) -> Self { self.powf(power) }
131-
175+
fn powf(self, power: Self) -> Self {
176+
self.powf(power)
177+
}
178+
132179
#[inline]
133-
fn tan(self) -> Self { self.tan() }
180+
fn tan(self) -> Self {
181+
self.tan()
182+
}
183+
134184
#[inline]
135-
fn log_gamma(self) -> Self { log_gamma(self) }
185+
fn log_gamma(self) -> Self {
186+
log_gamma(self)
187+
}
136188
}
137189

138190
/// Calculates ln(gamma(x)) (natural logarithm of the gamma

rand_distr/src/weibull.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ mod tests {
100100

101101
#[test]
102102
fn value_stability() {
103-
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>
104-
(distr: D, zero: N, expected: &[N])
105-
{
103+
fn test_samples<N: Float + core::fmt::Debug, D: Distribution<N>>(
104+
distr: D, zero: N, expected: &[N],
105+
) {
106106
let mut rng = crate::test::rng(213);
107107
let mut buf = [zero; 4];
108108
for x in &mut buf {

rand_hc/src/hc128.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ impl BlockRngCore for Hc128Core {
173173
impl Hc128Core {
174174
// One step of HC-128, update P and generate 32 bits keystream
175175
#[inline(always)]
176-
fn step_p(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize)
177-
-> u32
178-
{
176+
fn step_p(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) -> u32 {
179177
let (p, q) = self.t.split_at_mut(512);
180178
// FIXME: it would be great if we the bounds checks here could be
181179
// optimized out, and we would not need unsafe.
@@ -202,9 +200,7 @@ impl Hc128Core {
202200
// Similar to `step_p`, but `p` and `q` are swapped, and the rotates are to
203201
// the left instead of to the right.
204202
#[inline(always)]
205-
fn step_q(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize)
206-
-> u32
207-
{
203+
fn step_q(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) -> u32 {
208204
let (p, q) = self.t.split_at_mut(512);
209205
unsafe {
210206
let temp0 = q.get_unchecked(i511).rotate_left(23);

src/distributions/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ mod tests {
386386

387387
#[test]
388388
fn test_make_an_iter() {
389-
fn ten_dice_rolls_other_than_five<'a, R: Rng>(rng: &'a mut R) -> impl Iterator<Item = i32> + 'a {
389+
fn ten_dice_rolls_other_than_five<'a, R: Rng>(
390+
rng: &'a mut R,
391+
) -> impl Iterator<Item = i32> + 'a {
390392
Uniform::new_inclusive(1, 6)
391393
.sample_iter(rng)
392394
.filter(|x| *x != 5)

0 commit comments

Comments
 (0)