From 89a9dedcd519cad6567c19d0a8c2bd8f06330be6 Mon Sep 17 00:00:00 2001 From: Linus Behrbohm Date: Mon, 22 Feb 2021 01:03:46 +0100 Subject: [PATCH] cargo fmt --- src/base/allocator.rs | 2 +- src/base/conversion.rs | 5 ++-- src/base/iter.rs | 54 +++++++++++++++++++++++------------------- src/base/matrix.rs | 7 +++--- 4 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/base/allocator.rs b/src/base/allocator.rs index d2ef3bc0..2932b73e 100644 --- a/src/base/allocator.rs +++ b/src/base/allocator.rs @@ -18,7 +18,7 @@ use crate::base::{DefaultAllocator, Scalar}; /// same `Buffer` type. pub trait Allocator: Any + Sized { /// The type of buffer this allocator can instanciate. - type Buffer: ContiguousStorageMut + Clone + IntoIterator; + type Buffer: ContiguousStorageMut + Clone + IntoIterator; /// Allocates a buffer with the given number of rows and columns without initializing its content. unsafe fn allocate_uninitialized(nrows: R, ncols: C) -> Self::Buffer; diff --git a/src/base/conversion.rs b/src/base/conversion.rs index db949c13..5a156be4 100644 --- a/src/base/conversion.rs +++ b/src/base/conversion.rs @@ -21,7 +21,7 @@ use crate::base::dimension::{ Dim, DimName, U1, U10, U11, U12, U13, U14, U15, U16, U2, U3, U4, U5, U6, U7, U8, U9, }; use crate::base::iter::{MatrixIter, MatrixIterMut}; -use crate::base::storage::{ContiguousStorage, ContiguousStorageMut, Storage, StorageMut, Owned}; +use crate::base::storage::{ContiguousStorage, ContiguousStorageMut, Owned, Storage, StorageMut}; use crate::base::{ ArrayStorage, DVectorSlice, DVectorSliceMut, DefaultAllocator, Matrix, MatrixMN, MatrixSlice, MatrixSliceMut, Scalar, @@ -87,7 +87,8 @@ where } impl IntoIterator for Matrix> - where DefaultAllocator: Allocator +where + DefaultAllocator: Allocator, { type Item = N; type IntoIter = as IntoIterator>::IntoIter; diff --git a/src/base/iter.rs b/src/base/iter.rs index f9300c80..450d31aa 100644 --- a/src/base/iter.rs +++ b/src/base/iter.rs @@ -3,9 +3,9 @@ use std::marker::PhantomData; use std::mem; -use crate::base::dimension::{Dim, U1, Dynamic}; -use crate::base::storage::{Storage, StorageMut, Owned}; -use crate::base::{Matrix, MatrixSlice, MatrixSliceMut, Scalar, Vector, RowVector}; +use crate::base::dimension::{Dim, Dynamic, U1}; +use crate::base::storage::{Owned, Storage, StorageMut}; +use crate::base::{Matrix, MatrixSlice, MatrixSliceMut, RowVector, Scalar, Vector}; macro_rules! iterator { (struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty) => { @@ -252,12 +252,19 @@ impl OwnedRowIter { rows[i % nrows].push(item); i += 1; } - let rows: Vec>> = - rows.into_iter() - .map(|row| RowVector::>::from_iterator_generic( - U1::from_usize(1), Dynamic::from_usize(ncols), row.into_iter())) - .collect(); - OwnedRowIter { rows: rows.into_iter() } + let rows: Vec>> = rows + .into_iter() + .map(|row| { + RowVector::>::from_iterator_generic( + U1::from_usize(1), + Dynamic::from_usize(ncols), + row.into_iter(), + ) + }) + .collect(); + OwnedRowIter { + rows: rows.into_iter(), + } } } @@ -280,9 +287,7 @@ impl Iterator for OwnedRowIter { } } -impl ExactSizeIterator - for OwnedRowIter -{ +impl ExactSizeIterator for OwnedRowIter { #[inline] fn len(&self) -> usize { self.rows.len() @@ -418,17 +423,19 @@ impl OwnedColumnIter { cols[i / nrows].push(item); i += 1; } - let cols: Vec>> = - cols.into_iter() - .map(|col| - Vector::>::from_iterator_generic( - Dynamic::from_usize(nrows), - U1::from_usize(1), - col.into_iter() - ) + let cols: Vec>> = cols + .into_iter() + .map(|col| { + Vector::>::from_iterator_generic( + Dynamic::from_usize(nrows), + U1::from_usize(1), + col.into_iter(), ) - .collect(); - OwnedColumnIter { cols: cols.into_iter() } + }) + .collect(); + OwnedColumnIter { + cols: cols.into_iter(), + } } } @@ -451,8 +458,7 @@ impl Iterator for OwnedColumnIter { } } -impl ExactSizeIterator - for OwnedColumnIter { +impl ExactSizeIterator for OwnedColumnIter { #[inline] fn len(&self) -> usize { self.cols.len() diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 4b3b2d5b..3458c934 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -21,12 +21,13 @@ use simba::simd::SimdPartialOrd; use crate::base::allocator::{Allocator, SameShapeAllocator, SameShapeC, SameShapeR}; use crate::base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; -use crate::base::dimension::{Dim, DimAdd, DimSum, IsNotStaticOne, U1, U2, U3, Dynamic}; +use crate::base::dimension::{Dim, DimAdd, DimSum, Dynamic, IsNotStaticOne, U1, U2, U3}; use crate::base::iter::{ - ColumnIter, ColumnIterMut, OwnedColumnIter, MatrixIter, MatrixIterMut, RowIter, RowIterMut, OwnedRowIter, + ColumnIter, ColumnIterMut, MatrixIter, MatrixIterMut, OwnedColumnIter, OwnedRowIter, RowIter, + RowIterMut, }; use crate::base::storage::{ - ContiguousStorage, ContiguousStorageMut, SameShapeStorage, Storage, StorageMut, Owned + ContiguousStorage, ContiguousStorageMut, Owned, SameShapeStorage, Storage, StorageMut, }; use crate::base::{DefaultAllocator, MatrixMN, MatrixN, Scalar, Unit, VectorN}; use crate::SimdComplexField;