Skip to content

Commit 1f8e00a

Browse files
FreezyLemonYeungOnion
authored andcommitted
style: inline format args
Stable since 1.58.0
1 parent cc83c6f commit 1f8e00a

File tree

10 files changed

+31
-33
lines changed

10 files changed

+31
-33
lines changed

src/distribution/chi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ mod tests {
381381
fn test_large_dof_mean_not_nan() {
382382
for i in 1..1000 {
383383
let mean = Chi::new(i as f64).unwrap().mean().unwrap();
384-
assert!(!mean.is_nan(), "Chi mean for {} dof was {}", i, mean);
384+
assert!(!mean.is_nan(), "Chi mean for {i} dof was {mean}");
385385
}
386386
}
387387

src/distribution/empirical.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ impl std::fmt::Display for Empirical {
159159
.flat_map(|(&NonNan(x), &count)| std::iter::repeat(x).take(count as usize));
160160

161161
if let Some(x) = enumerated_values.next() {
162-
write!(f, "Empirical([{:.3e}", x)?;
162+
write!(f, "Empirical([{x:.3e}")?;
163163
} else {
164164
return write!(f, "Empirical(∅)");
165165
}
166166

167167
for val in enumerated_values.by_ref().take(4) {
168-
write!(f, ", {:.3e}", val)?;
168+
write!(f, ", {val:.3e}")?;
169169
}
170170
if enumerated_values.next().is_some() {
171171
write!(f, ", ...")?;

src/distribution/internal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ pub mod test {
377377
let cdf = dist.cdf(x);
378378
if (sum - cdf).abs() > 1e-3 {
379379
println!("Integral of pdf doesn't equal cdf!");
380-
println!("Integration from {} by {} to {} = {}", x_min, step, x, sum);
381-
println!("cdf = {}", cdf);
380+
println!("Integration from {x_min} by {step} to {x} = {sum}");
381+
println!("cdf = {cdf}");
382382
panic!();
383383
}
384384

src/distribution/laplace.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,7 @@ mod tests {
588588
});
589589
assert!(
590590
result > -tolerance && result < tolerance,
591-
"Balance is {} for seed {}",
592-
result,
593-
seed
591+
"Balance is {result} for seed {seed}"
594592
);
595593
}
596594
}

src/distribution/uniform.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl ContinuousCDF<f64, f64> for Uniform {
168168
/// Finds the value of `x` where `F(p) = x`
169169
fn inverse_cdf(&self, p: f64) -> f64 {
170170
if !(0.0..=1.0).contains(&p) {
171-
panic!("p must be in [0, 1], was {}", p);
171+
panic!("p must be in [0, 1], was {p}");
172172
} else if p == 0.0 {
173173
self.min
174174
} else if p == 1.0 {

src/error.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,50 +56,50 @@ impl fmt::Display for StatsError {
5656
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5757
match *self {
5858
StatsError::BadParams => write!(f, "Bad distribution parameters"),
59-
StatsError::ArgFinite(s) => write!(f, "Argument {} must be finite", s),
60-
StatsError::ArgMustBePositive(s) => write!(f, "Argument {} must be positive", s),
61-
StatsError::ArgNotNegative(s) => write!(f, "Argument {} must be non-negative", s),
59+
StatsError::ArgFinite(s) => write!(f, "Argument {s} must be finite"),
60+
StatsError::ArgMustBePositive(s) => write!(f, "Argument {s} must be positive"),
61+
StatsError::ArgNotNegative(s) => write!(f, "Argument {s} must be non-negative"),
6262
StatsError::ArgIntervalIncl(s, min, max) => {
63-
write!(f, "Argument {} not within interval [{}, {}]", s, min, max)
63+
write!(f, "Argument {s} not within interval [{min}, {max}]")
6464
}
6565
StatsError::ArgIntervalExcl(s, min, max) => {
66-
write!(f, "Argument {} not within interval ({}, {})", s, min, max)
66+
write!(f, "Argument {s} not within interval ({min}, {max})")
6767
}
6868
StatsError::ArgIntervalExclMin(s, min, max) => {
69-
write!(f, "Argument {} not within interval ({}, {}]", s, min, max)
69+
write!(f, "Argument {s} not within interval ({min}, {max}]")
7070
}
7171
StatsError::ArgIntervalExclMax(s, min, max) => {
72-
write!(f, "Argument {} not within interval [{}, {})", s, min, max)
72+
write!(f, "Argument {s} not within interval [{min}, {max})")
7373
}
74-
StatsError::ArgGt(s, val) => write!(f, "Argument {} must be greater than {}", s, val),
74+
StatsError::ArgGt(s, val) => write!(f, "Argument {s} must be greater than {val}"),
7575
StatsError::ArgGtArg(s, val) => {
76-
write!(f, "Argument {} must be greater than {}", s, val)
76+
write!(f, "Argument {s} must be greater than {val}")
7777
}
7878
StatsError::ArgGte(s, val) => {
79-
write!(f, "Argument {} must be greater than or equal to {}", s, val)
79+
write!(f, "Argument {s} must be greater than or equal to {val}")
8080
}
8181
StatsError::ArgGteArg(s, val) => {
82-
write!(f, "Argument {} must be greater than or equal to {}", s, val)
82+
write!(f, "Argument {s} must be greater than or equal to {val}")
8383
}
84-
StatsError::ArgLt(s, val) => write!(f, "Argument {} must be less than {}", s, val),
85-
StatsError::ArgLtArg(s, val) => write!(f, "Argument {} must be less than {}", s, val),
84+
StatsError::ArgLt(s, val) => write!(f, "Argument {s} must be less than {val}"),
85+
StatsError::ArgLtArg(s, val) => write!(f, "Argument {s} must be less than {val}"),
8686
StatsError::ArgLte(s, val) => {
87-
write!(f, "Argument {} must be less than or equal to {}", s, val)
87+
write!(f, "Argument {s} must be less than or equal to {val}")
8888
}
8989
StatsError::ArgLteArg(s, val) => {
90-
write!(f, "Argument {} must be less than or equal to {}", s, val)
90+
write!(f, "Argument {s} must be less than or equal to {val}")
9191
}
9292
StatsError::ContainersMustBeSameLength => {
9393
write!(f, "Expected containers of same length")
9494
}
9595
StatsError::ComputationFailedToConverge => write!(f, "Computation failed to converge"),
9696
StatsError::ContainerExpectedSum(s, sum) => {
97-
write!(f, "Elements in container {} expected to sum to {}", s, sum)
97+
write!(f, "Elements in container {s} expected to sum to {sum}")
9898
}
9999
StatsError::ContainerExpectedSumVar(s, sum) => {
100-
write!(f, "Elements in container {} expected to sum to {}", s, sum)
100+
write!(f, "Elements in container {s} expected to sum to {sum}")
101101
}
102-
StatsError::SpecialCase(s) => write!(f, "{}", s),
102+
StatsError::SpecialCase(s) => write!(f, "{s}"),
103103
}
104104
}
105105
}

src/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl InfinitePeriodic {
8383

8484
impl std::fmt::Display for InfinitePeriodic {
8585
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
86-
write!(f, "{:#?}", self)
86+
write!(f, "{self:#?}")
8787
}
8888
}
8989

src/statistics/slice_statistics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ where
1414
write!(f, "Data([")?;
1515

1616
if let Some(v) = tee.next() {
17-
write!(f, "{}", v)?;
17+
write!(f, "{v}")?;
1818
}
1919
for _ in 1..5 {
2020
if let Some(v) = tee.next() {
21-
write!(f, ", {}", v)?;
21+
write!(f, ", {v}")?;
2222
}
2323
}
2424
if tee.next().is_some() {

src/stats_tests/fisher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl std::fmt::Display for FishersExactTestError {
111111
FishersExactTestError::TableInvalidForHypergeometric(hg_err) => {
112112
writeln!(f, "Cannot create a Hypergeometric distribution from the data in the contingency table.")?;
113113
writeln!(f, "Is it in row-major order?")?;
114-
write!(f, "Inner error: '{}'", hg_err)
114+
write!(f, "Inner error: '{hg_err}'")
115115
}
116116
}
117117
}

tests/nist_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn nist_strd_univariate_mean() {
7676
for fname in FILENAMES {
7777
let filepath = get_path(fname, env::var(NIST_DATA_DIR_ENV).ok().as_deref());
7878
let case = parse_file(filepath)
79-
.unwrap_or_else(|e| panic!("failed parsing file {} with `{:?}`", fname, e));
79+
.unwrap_or_else(|e| panic!("failed parsing file {fname} with `{e:?}`"));
8080
assert_relative_eq!(case.values.mean(), case.certified.mean, epsilon = 1e-12);
8181
}
8282
}
@@ -87,7 +87,7 @@ fn nist_strd_univariate_std_dev() {
8787
for fname in FILENAMES {
8888
let filepath = get_path(fname, env::var(NIST_DATA_DIR_ENV).ok().as_deref());
8989
let case = parse_file(filepath)
90-
.unwrap_or_else(|e| panic!("failed parsing file {} with `{:?}`", fname, e));
90+
.unwrap_or_else(|e| panic!("failed parsing file {fname} with `{e:?}`"));
9191
assert_relative_eq!(
9292
case.values.std_dev(),
9393
case.certified.std_dev,

0 commit comments

Comments
 (0)