Add rustfmt.toml and reformat.

This commit is contained in:
Dimitri Sabadie 2020-03-19 01:22:26 +01:00
parent 1bcf1de99e
commit 89dfb61272
No known key found for this signature in database
GPG Key ID: 23CDFD7CAFBA2EDC
11 changed files with 751 additions and 745 deletions

15
rustfmt.toml Normal file
View File

@ -0,0 +1,15 @@
edition = "2018"
fn_args_layout = "Tall"
force_explicit_abi = true
hard_tabs = false
max_width = 100
merge_derives = true
newline_style = "Unix"
remove_nested_parens = true
reorder_imports = true
reorder_modules = true
tab_spaces = 2
use_field_init_shorthand = true
use_small_heuristics = "Default"
use_try_shorthand = true

View File

@ -262,13 +262,7 @@ macro_rules! impl_interpolate_simple {
a * (1. - t) + b * t a * (1. - t) + b * t
} }
fn cubic_hermite( fn cubic_hermite(x: (Self, $t), a: (Self, $t), b: (Self, $t), y: (Self, $t), t: $t) -> Self {
x: (Self, $t),
a: (Self, $t),
b: (Self, $t),
y: (Self, $t),
t: $t,
) -> Self {
cubic_hermite_def(x, a, b, y, t) cubic_hermite_def(x, a, b, y, t)
} }

View File

@ -39,7 +39,8 @@ impl<T, V> Spline<T, V> {
where where
T: PartialOrd, T: PartialOrd,
{ {
self.0 self
.0
.sort_by(|k0, k1| k0.t.partial_cmp(&k1.t).unwrap_or(Ordering::Less)); .sort_by(|k0, k1| k0.t.partial_cmp(&k1.t).unwrap_or(Ordering::Less));
} }
@ -165,13 +166,9 @@ impl<T, V> Spline<T, V> {
let nt = normalize_time(t, cp0, cp1); let nt = normalize_time(t, cp0, cp1);
let value = match cp1.interpolation { let value = match cp1.interpolation {
Interpolation::Bezier(v) => Interpolate::cubic_bezier( Interpolation::Bezier(v) => {
cp0.value, Interpolate::cubic_bezier(cp0.value, u, cp1.value + cp1.value - v, cp1.value, nt)
u, }
cp1.value + cp1.value - v,
cp1.value,
nt,
),
Interpolation::StrokeBezier(v, _) => { Interpolation::StrokeBezier(v, _) => {
Interpolate::cubic_bezier(cp0.value, u, v, cp1.value, nt) Interpolate::cubic_bezier(cp0.value, u, v, cp1.value, nt)