From 6243a5ecd9ffc239f1f7a647ced265af05f7b2f2 Mon Sep 17 00:00:00 2001 From: Andrew Champion Date: Fri, 11 Dec 2020 13:20:00 +0000 Subject: [PATCH] Fmt: use vertical imports These have less noisy line edits. --- .rustfmt.toml | 1 + benches/parallel_write.rs | 15 ++++++++--- benches/simple.rs | 11 ++++++-- src/compression/bzip.rs | 10 ++++++-- src/compression/gzip.rs | 10 ++++++-- src/compression/lz.rs | 21 +++++++++++++--- src/compression/lz_pure.rs | 16 +++++++++--- src/compression/mod.rs | 12 ++++++--- src/compression/raw.rs | 10 ++++++-- src/compression/xz.rs | 10 ++++++-- src/data_type.rs | 5 +++- src/filesystem.rs | 51 ++++++++++++++++++++++++++++++++------ src/lib.rs | 17 ++++++++++--- src/ndarray.rs | 33 ++++++++++++++++++++---- src/prelude.rs | 19 +++++++++++--- src/tests.rs | 5 +++- tests/integration_test.rs | 5 +++- 17 files changed, 206 insertions(+), 45 deletions(-) create mode 100644 .rustfmt.toml diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..d82647b --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1 @@ +imports_layout = "Vertical" diff --git a/benches/parallel_write.rs b/benches/parallel_write.rs index 4516453..ab105c8 100644 --- a/benches/parallel_write.rs +++ b/benches/parallel_write.rs @@ -17,12 +17,21 @@ extern crate test; use std::fs::File; use std::io::BufReader; -use futures::{self, Future}; -use futures_cpupool::{CpuFuture, CpuPool}; +use futures::{ + self, + Future, +}; +use futures_cpupool::{ + CpuFuture, + CpuPool, +}; use lazy_static::lazy_static; use tempdir; use test::Bencher; -use tiff::decoder::{Decoder, DecodingResult}; +use tiff::decoder::{ + Decoder, + DecodingResult, +}; use n5::prelude::*; use n5::smallvec::smallvec; diff --git a/benches/simple.rs b/benches/simple.rs index c29e8f4..0f0f101 100644 --- a/benches/simple.rs +++ b/benches/simple.rs @@ -3,12 +3,19 @@ extern crate test; -use rand::{distributions::Standard, Rng}; +use rand::{ + distributions::Standard, + Rng, +}; use test::Bencher; use n5::prelude::*; use n5::smallvec::smallvec; -use n5::{DefaultBlock, DefaultBlockReader, DefaultBlockWriter}; +use n5::{ + DefaultBlock, + DefaultBlockReader, + DefaultBlockWriter, +}; fn test_block_compression_rw(compression: compression::CompressionType, b: &mut Bencher) where diff --git a/src/compression/bzip.rs b/src/compression/bzip.rs index 1c692d3..6490dfb 100644 --- a/src/compression/bzip.rs +++ b/src/compression/bzip.rs @@ -1,9 +1,15 @@ -use std::io::{Read, Write}; +use std::io::{ + Read, + Write, +}; use bzip2::read::BzDecoder; use bzip2::write::BzEncoder; use bzip2::Compression as BzCompression; -use serde::{Deserialize, Serialize}; +use serde::{ + Deserialize, + Serialize, +}; use super::Compression; diff --git a/src/compression/gzip.rs b/src/compression/gzip.rs index 73ee9af..d6691da 100644 --- a/src/compression/gzip.rs +++ b/src/compression/gzip.rs @@ -1,9 +1,15 @@ -use std::io::{Read, Write}; +use std::io::{ + Read, + Write, +}; use flate2::read::GzDecoder; use flate2::write::GzEncoder; use flate2::Compression as GzCompression; -use serde::{Deserialize, Serialize}; +use serde::{ + Deserialize, + Serialize, +}; use super::Compression; diff --git a/src/compression/lz.rs b/src/compression/lz.rs index b54fd1c..7c7c748 100644 --- a/src/compression/lz.rs +++ b/src/compression/lz.rs @@ -1,7 +1,20 @@ -use std::io::{Read, Result, Write}; - -use lz4::{BlockMode, BlockSize, Decoder, Encoder, EncoderBuilder}; -use serde::{Deserialize, Serialize}; +use std::io::{ + Read, + Result, + Write, +}; + +use lz4::{ + BlockMode, + BlockSize, + Decoder, + Encoder, + EncoderBuilder, +}; +use serde::{ + Deserialize, + Serialize, +}; use super::Compression; diff --git a/src/compression/lz_pure.rs b/src/compression/lz_pure.rs index 119103b..c41ca41 100644 --- a/src/compression/lz_pure.rs +++ b/src/compression/lz_pure.rs @@ -1,7 +1,17 @@ -use std::io::{Read, Result, Write}; +use std::io::{ + Read, + Result, + Write, +}; -use lz_fear::framed::{CompressionSettings, LZ4FrameReader}; -use serde::{Deserialize, Serialize}; +use lz_fear::framed::{ + CompressionSettings, + LZ4FrameReader, +}; +use serde::{ + Deserialize, + Serialize, +}; use super::Compression; diff --git a/src/compression/mod.rs b/src/compression/mod.rs index b9c4e11..4ed098b 100644 --- a/src/compression/mod.rs +++ b/src/compression/mod.rs @@ -1,8 +1,14 @@ //! Compression for block voxel data. -use std::io::{Read, Write}; - -use serde::{Deserialize, Serialize}; +use std::io::{ + Read, + Write, +}; + +use serde::{ + Deserialize, + Serialize, +}; #[cfg(feature = "bzip")] pub mod bzip; diff --git a/src/compression/raw.rs b/src/compression/raw.rs index dde3f22..0e0a847 100644 --- a/src/compression/raw.rs +++ b/src/compression/raw.rs @@ -1,6 +1,12 @@ -use std::io::{Read, Write}; +use std::io::{ + Read, + Write, +}; -use serde::{Deserialize, Serialize}; +use serde::{ + Deserialize, + Serialize, +}; use super::Compression; diff --git a/src/compression/xz.rs b/src/compression/xz.rs index 0ed7229..8efd772 100644 --- a/src/compression/xz.rs +++ b/src/compression/xz.rs @@ -1,6 +1,12 @@ -use std::io::{Read, Write}; +use std::io::{ + Read, + Write, +}; -use serde::{Deserialize, Serialize}; +use serde::{ + Deserialize, + Serialize, +}; use xz2::read::XzDecoder; use xz2::write::XzEncoder; diff --git a/src/data_type.rs b/src/data_type.rs index 750c058..73a1d0b 100644 --- a/src/data_type.rs +++ b/src/data_type.rs @@ -1,4 +1,7 @@ -use serde::{Deserialize, Serialize}; +use serde::{ + Deserialize, + Serialize, +}; use crate::BlockHeader; use crate::VecDataBlock; diff --git a/src/filesystem.rs b/src/filesystem.rs index 482d4e4..d8b9839 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -1,18 +1,47 @@ //! A filesystem-backed N5 container. -use std::fs::{self, File}; -use std::io::{BufReader, BufWriter, Error, ErrorKind, Read, Result, Seek, SeekFrom}; +use std::fs::{ + self, + File, +}; +use std::io::{ + BufReader, + BufWriter, + Error, + ErrorKind, + Read, + Result, + Seek, + SeekFrom, +}; use std::path::PathBuf; use std::str::FromStr; use fs2::FileExt; -use serde_json::{self, json, Value}; +use serde_json::{ + self, + json, + Value, +}; use walkdir::WalkDir; use crate::{ - is_version_compatible, DataBlock, DataBlockMetadata, DatasetAttributes, DefaultBlockReader, - DefaultBlockWriter, GridCoord, N5Lister, N5Reader, N5Writer, ReadableDataBlock, ReflectedType, - ReinitDataBlock, VecDataBlock, Version, WriteableDataBlock, + is_version_compatible, + DataBlock, + DataBlockMetadata, + DatasetAttributes, + DefaultBlockReader, + DefaultBlockWriter, + GridCoord, + N5Lister, + N5Reader, + N5Writer, + ReadableDataBlock, + ReflectedType, + ReinitDataBlock, + VecDataBlock, + Version, + WriteableDataBlock, }; /// Name of the attributes file stored in the container root and dataset dirs. @@ -92,7 +121,10 @@ impl N5Filesystem { // Note: cannot use `canonicalize` on both the constructed dataset path // and `base_path` and check `starts_with`, because `canonicalize` also // requires the path exist. - use std::path::{Component, Path}; + use std::path::{ + Component, + Path, + }; // Normalize the path to be relative. let mut components = Path::new(path_name).components(); @@ -394,7 +426,10 @@ impl N5Writer for N5Filesystem { mod tests { use super::*; use crate::test_backend; - use crate::tests::{ContextWrapper, N5Testable}; + use crate::tests::{ + ContextWrapper, + N5Testable, + }; use tempdir::TempDir; impl crate::tests::N5Testable for N5Filesystem { diff --git a/src/lib.rs b/src/lib.rs index e183114..ffe8c77 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,12 +14,23 @@ doc_comment::doctest!("../README.md"); #[macro_use] pub extern crate smallvec; -use std::io::{Error, ErrorKind}; +use std::io::{ + Error, + ErrorKind, +}; use std::marker::PhantomData; use std::time::SystemTime; -use byteorder::{BigEndian, ByteOrder, ReadBytesExt, WriteBytesExt}; -use serde::{Deserialize, Serialize}; +use byteorder::{ + BigEndian, + ByteOrder, + ReadBytesExt, + WriteBytesExt, +}; +use serde::{ + Deserialize, + Serialize, +}; use smallvec::SmallVec; use crate::compression::Compression; diff --git a/src/ndarray.rs b/src/ndarray.rs index c513afe..517b025 100644 --- a/src/ndarray.rs +++ b/src/ndarray.rs @@ -1,18 +1,41 @@ use std::cmp; -use std::io::{Error, ErrorKind}; +use std::io::{ + Error, + ErrorKind, +}; use std::ops::Sub; use itertools::Itertools; -use ndarray::{Array, ArrayView, IxDyn, ShapeBuilder, SliceInfo}; +use ndarray::{ + Array, + ArrayView, + IxDyn, + ShapeBuilder, + SliceInfo, +}; use crate::{ - BlockCoord, CoordVec, DataBlock, DatasetAttributes, GridCoord, N5Reader, N5Writer, - ReadableDataBlock, ReflectedType, ReinitDataBlock, SliceDataBlock, VecDataBlock, + BlockCoord, + CoordVec, + DataBlock, + DatasetAttributes, + GridCoord, + N5Reader, + N5Writer, + ReadableDataBlock, + ReflectedType, + ReinitDataBlock, + SliceDataBlock, + VecDataBlock, WriteableDataBlock, }; pub mod prelude { - pub use super::{BoundingBox, N5NdarrayReader, N5NdarrayWriter}; + pub use super::{ + BoundingBox, + N5NdarrayReader, + N5NdarrayWriter, + }; } /// Specifes the extents of an axis-aligned bounding box. diff --git a/src/prelude.rs b/src/prelude.rs index aa1a2ec..51998f1 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -10,12 +10,25 @@ //! ``` #[doc(no_inline)] -pub use crate::compression::{self, CompressionType}; +pub use crate::compression::{ + self, + CompressionType, +}; #[cfg(feature = "filesystem")] #[doc(no_inline)] pub use crate::filesystem::N5Filesystem; #[doc(no_inline)] pub use crate::{ - BlockCoord, DataBlock, DataBlockMetadata, DataType, DatasetAttributes, GridCoord, N5Lister, - N5Reader, N5Writer, ReflectedType, SliceDataBlock, VecDataBlock, + BlockCoord, + DataBlock, + DataBlockMetadata, + DataType, + DatasetAttributes, + GridCoord, + N5Lister, + N5Reader, + N5Writer, + ReflectedType, + SliceDataBlock, + VecDataBlock, }; diff --git a/src/tests.rs b/src/tests.rs index d4ed1dc..e5b10c3 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,5 +1,8 @@ use super::*; -use std::io::{Cursor, Result}; +use std::io::{ + Cursor, + Result, +}; use serde_json::json; diff --git a/tests/integration_test.rs b/tests/integration_test.rs index c62ad8e..ec32fd1 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -1,4 +1,7 @@ -use rand::{distributions::Standard, Rng}; +use rand::{ + distributions::Standard, + Rng, +}; use smallvec::smallvec; use n5::prelude::*;