Skip to content

Commit e750399

Browse files
committed
nightly fmt
1 parent 4d0bbc0 commit e750399

File tree

3 files changed

+43
-32
lines changed

3 files changed

+43
-32
lines changed

src/finite_bounds.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
use num_traits::Float;
22

3-
pub enum Bound<F> {
3+
pub enum Bound<F>
4+
{
45
Included(F),
56
Excluded(F),
67
}
78

89
/// A version of std::ops::RangeBounds that only implements a..b and a..=b ranges.
9-
pub trait FiniteBounds<F> {
10+
pub trait FiniteBounds<F>
11+
{
1012
fn start_bound(&self) -> F;
1113
fn end_bound(&self) -> Bound<F>;
1214
}
1315

1416
impl<F> FiniteBounds<F> for std::ops::Range<F>
15-
where
16-
F: Float,
17+
where F: Float
1718
{
18-
fn start_bound(&self) -> F {
19+
fn start_bound(&self) -> F
20+
{
1921
self.start
2022
}
2123

22-
fn end_bound(&self) -> Bound<F> {
24+
fn end_bound(&self) -> Bound<F>
25+
{
2326
Bound::Excluded(self.end)
2427
}
2528
}
2629

2730
impl<F> FiniteBounds<F> for std::ops::RangeInclusive<F>
28-
where
29-
F: Float,
31+
where F: Float
3032
{
31-
fn start_bound(&self) -> F {
33+
fn start_bound(&self) -> F
34+
{
3235
*self.start()
3336
}
3437

35-
fn end_bound(&self) -> Bound<F> {
38+
fn end_bound(&self) -> Bound<F>
39+
{
3640
Bound::Included(*self.end())
3741
}
3842
}

src/linspace.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ use num_traits::Float;
1414
/// An iterator of a sequence of evenly spaced floats.
1515
///
1616
/// Iterator element type is `F`.
17-
pub struct Linspace<F> {
17+
pub struct Linspace<F>
18+
{
1819
start: F,
1920
step: F,
2021
index: usize,
2122
len: usize,
2223
}
2324

2425
impl<F> Iterator for Linspace<F>
25-
where
26-
F: Float,
26+
where F: Float
2727
{
2828
type Item = F;
2929

3030
#[inline]
31-
fn next(&mut self) -> Option<F> {
31+
fn next(&mut self) -> Option<F>
32+
{
3233
if self.index >= self.len {
3334
None
3435
} else {
@@ -40,18 +41,19 @@ where
4041
}
4142

4243
#[inline]
43-
fn size_hint(&self) -> (usize, Option<usize>) {
44+
fn size_hint(&self) -> (usize, Option<usize>)
45+
{
4446
let n = self.len - self.index;
4547
(n, Some(n))
4648
}
4749
}
4850

4951
impl<F> DoubleEndedIterator for Linspace<F>
50-
where
51-
F: Float,
52+
where F: Float
5253
{
5354
#[inline]
54-
fn next_back(&mut self) -> Option<F> {
55+
fn next_back(&mut self) -> Option<F>
56+
{
5557
if self.index >= self.len {
5658
None
5759
} else {
@@ -111,8 +113,7 @@ where
111113
/// **Panics** if converting `((b - a) / step).ceil()` to type `F` fails.
112114
#[inline]
113115
pub fn range<F>(a: F, b: F, step: F) -> Linspace<F>
114-
where
115-
F: Float,
116+
where F: Float
116117
{
117118
let len = b - a;
118119
let steps = F::ceil(len / step);

src/logspace.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ use num_traits::Float;
1414
/// An iterator of a sequence of logarithmically spaced number.
1515
///
1616
/// Iterator element type is `F`.
17-
pub struct Logspace<F> {
17+
pub struct Logspace<F>
18+
{
1819
sign: F,
1920
base: F,
2021
start: F,
@@ -24,13 +25,13 @@ pub struct Logspace<F> {
2425
}
2526

2627
impl<F> Iterator for Logspace<F>
27-
where
28-
F: Float,
28+
where F: Float
2929
{
3030
type Item = F;
3131

3232
#[inline]
33-
fn next(&mut self) -> Option<F> {
33+
fn next(&mut self) -> Option<F>
34+
{
3435
if self.index >= self.len {
3536
None
3637
} else {
@@ -43,18 +44,19 @@ where
4344
}
4445

4546
#[inline]
46-
fn size_hint(&self) -> (usize, Option<usize>) {
47+
fn size_hint(&self) -> (usize, Option<usize>)
48+
{
4749
let n = self.len - self.index;
4850
(n, Some(n))
4951
}
5052
}
5153

5254
impl<F> DoubleEndedIterator for Logspace<F>
53-
where
54-
F: Float,
55+
where F: Float
5556
{
5657
#[inline]
57-
fn next_back(&mut self) -> Option<F> {
58+
fn next_back(&mut self) -> Option<F>
59+
{
5860
if self.index >= self.len {
5961
None
6062
} else {
@@ -107,12 +109,14 @@ where
107109
}
108110

109111
#[cfg(test)]
110-
mod tests {
112+
mod tests
113+
{
111114
use super::logspace;
112115

113116
#[test]
114117
#[cfg(feature = "approx")]
115-
fn valid() {
118+
fn valid()
119+
{
116120
use crate::{arr1, Array1};
117121
use approx::assert_abs_diff_eq;
118122

@@ -130,7 +134,8 @@ mod tests {
130134
}
131135

132136
#[test]
133-
fn iter_forward() {
137+
fn iter_forward()
138+
{
134139
let mut iter = logspace(10.0f64, 0.0..=3.0, 4);
135140

136141
assert!(iter.size_hint() == (4, Some(4)));
@@ -145,7 +150,8 @@ mod tests {
145150
}
146151

147152
#[test]
148-
fn iter_backward() {
153+
fn iter_backward()
154+
{
149155
let mut iter = logspace(10.0f64, 0.0..=3.0, 4);
150156

151157
assert!(iter.size_hint() == (4, Some(4)));

0 commit comments

Comments
 (0)