From 508cda6021d7498696ace5c1badc72300e3e8067 Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Sun, 16 Dec 2018 13:14:06 -0800 Subject: [PATCH] Better path usage and "extern crate" removal in sub-crates. --- sub_crates/bvh_order/build.rs | 5 +---- sub_crates/color/build.rs | 5 +---- sub_crates/float4/src/lib.rs | 14 +++++++++----- sub_crates/halton/build.rs | 5 +---- sub_crates/math3d/src/lib.rs | 7 +------ sub_crates/math3d/src/matrix.rs | 1 - sub_crates/math3d/src/normal.rs | 9 +++++---- sub_crates/math3d/src/point.rs | 9 +++++---- sub_crates/math3d/src/vector.rs | 9 +++++---- sub_crates/mem_arena/src/lib.rs | 10 ++++++---- sub_crates/oct32norm/benches/bench.rs | 7 +------ sub_crates/sobol/src/lib.rs | 3 +-- sub_crates/spectra_xyz/src/lib.rs | 3 +-- sub_crates/trifloat/benches/bench.rs | 7 +------ 14 files changed, 38 insertions(+), 56 deletions(-) diff --git a/sub_crates/bvh_order/build.rs b/sub_crates/bvh_order/build.rs index 0b1d99e..7359d81 100644 --- a/sub_crates/bvh_order/build.rs +++ b/sub_crates/bvh_order/build.rs @@ -1,9 +1,6 @@ // Generate table for traversal order of quad BVHs. -use std::env; -use std::fs::File; -use std::io::Write; -use std::path::Path; +use std::{env, fs::File, io::Write, path::Path}; fn main() { // Build the traversal table. diff --git a/sub_crates/color/build.rs b/sub_crates/color/build.rs index 21b6ba7..eaeced1 100644 --- a/sub_crates/color/build.rs +++ b/sub_crates/color/build.rs @@ -1,7 +1,4 @@ -use std::env; -use std::fs::File; -use std::io::Write; -use std::path::Path; +use std::{env, fs::File, io::Write, path::Path}; #[derive(Copy, Clone)] struct Chromaticities { diff --git a/sub_crates/float4/src/lib.rs b/sub_crates/float4/src/lib.rs index f51485b..0ab9b37 100644 --- a/sub_crates/float4/src/lib.rs +++ b/sub_crates/float4/src/lib.rs @@ -3,9 +3,11 @@ /// Implementation of Float4 for x86_64 platforms with SSE support. #[cfg(all(target_arch = "x86_64", target_feature = "sse"))] mod x86_64_sse { - use std::arch::x86_64::__m128; - use std::cmp::PartialEq; - use std::ops::{Add, AddAssign, BitAnd, BitOr, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; + use std::{ + arch::x86_64::__m128, + cmp::PartialEq, + ops::{Add, AddAssign, BitAnd, BitOr, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}, + }; #[derive(Debug, Copy, Clone)] pub struct Float4 { @@ -626,8 +628,10 @@ mod x86_64_sse { /// Implementation fo Float4 for any platform, foregoing any /// platform-specific optimizations. mod fallback { - use std::cmp::PartialEq; - use std::ops::{Add, AddAssign, BitAnd, BitOr, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; + use std::{ + cmp::PartialEq, + ops::{Add, AddAssign, BitAnd, BitOr, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}, + }; #[derive(Debug, Copy, Clone)] pub struct Float4 { diff --git a/sub_crates/halton/build.rs b/sub_crates/halton/build.rs index d315a1e..43e7970 100644 --- a/sub_crates/halton/build.rs +++ b/sub_crates/halton/build.rs @@ -22,10 +22,7 @@ // Generate Rust code for evaluating Halton points with Faure-permutations for different bases. -use std::env; -use std::fs::File; -use std::io::Write; -use std::path::Path; +use std::{env, fs::File, io::Write, path::Path}; /// How many components to generate. const NUM_DIMENSIONS: usize = 128; diff --git a/sub_crates/math3d/src/lib.rs b/sub_crates/math3d/src/lib.rs index 056def9..6795dee 100644 --- a/sub_crates/math3d/src/lib.rs +++ b/sub_crates/math3d/src/lib.rs @@ -1,16 +1,11 @@ #![allow(dead_code)] -extern crate float4; - mod matrix; mod normal; mod point; mod vector; -pub use self::matrix::Matrix4x4; -pub use self::normal::Normal; -pub use self::point::Point; -pub use self::vector::Vector; +pub use self::{matrix::Matrix4x4, normal::Normal, point::Point, vector::Vector}; /// Trait for calculating dot products. pub trait DotProduct { diff --git a/sub_crates/math3d/src/matrix.rs b/sub_crates/math3d/src/matrix.rs index 756f29f..9b80c9c 100644 --- a/sub_crates/math3d/src/matrix.rs +++ b/sub_crates/math3d/src/matrix.rs @@ -1,6 +1,5 @@ #![allow(dead_code)] -use std; use std::ops::{Index, IndexMut, Mul}; use float4::{invert, transpose, Float4}; diff --git a/sub_crates/math3d/src/normal.rs b/sub_crates/math3d/src/normal.rs index 70c4f05..e1c9067 100644 --- a/sub_crates/math3d/src/normal.rs +++ b/sub_crates/math3d/src/normal.rs @@ -1,12 +1,13 @@ #![allow(dead_code)] -use std::cmp::PartialEq; -use std::ops::{Add, Div, Mul, Neg, Sub}; +use std::{ + cmp::PartialEq, + ops::{Add, Div, Mul, Neg, Sub}, +}; use float4::Float4; -use super::{CrossProduct, DotProduct}; -use super::{Matrix4x4, Vector}; +use super::{CrossProduct, DotProduct, Matrix4x4, Vector}; /// A surface normal in 3d homogeneous space. #[derive(Debug, Copy, Clone)] diff --git a/sub_crates/math3d/src/point.rs b/sub_crates/math3d/src/point.rs index aad0238..075fb9c 100644 --- a/sub_crates/math3d/src/point.rs +++ b/sub_crates/math3d/src/point.rs @@ -1,12 +1,13 @@ #![allow(dead_code)] -use std::cmp::PartialEq; -use std::ops::{Add, Mul, Sub}; +use std::{ + cmp::PartialEq, + ops::{Add, Mul, Sub}, +}; use float4::Float4; -use super::Matrix4x4; -use super::Vector; +use super::{Matrix4x4, Vector}; /// A position in 3d homogeneous space. #[derive(Debug, Copy, Clone)] diff --git a/sub_crates/math3d/src/vector.rs b/sub_crates/math3d/src/vector.rs index 04ab7ea..6c6f9c0 100644 --- a/sub_crates/math3d/src/vector.rs +++ b/sub_crates/math3d/src/vector.rs @@ -1,12 +1,13 @@ #![allow(dead_code)] -use std::cmp::PartialEq; -use std::ops::{Add, Div, Mul, Neg, Sub}; +use std::{ + cmp::PartialEq, + ops::{Add, Div, Mul, Neg, Sub}, +}; use float4::Float4; -use super::{CrossProduct, DotProduct}; -use super::{Matrix4x4, Normal, Point}; +use super::{CrossProduct, DotProduct, Matrix4x4, Normal, Point}; /// A direction vector in 3d homogeneous space. #[derive(Debug, Copy, Clone)] diff --git a/sub_crates/mem_arena/src/lib.rs b/sub_crates/mem_arena/src/lib.rs index 8fc14bf..1c84a52 100644 --- a/sub_crates/mem_arena/src/lib.rs +++ b/sub_crates/mem_arena/src/lib.rs @@ -2,10 +2,12 @@ #![allow(clippy::needless_return)] #![allow(clippy::mut_from_ref)] -use std::cell::{Cell, RefCell}; -use std::cmp::max; -use std::mem::{align_of, size_of}; -use std::slice; +use std::{ + cell::{Cell, RefCell}, + cmp::max, + mem::{align_of, size_of}, + slice, +}; const GROWTH_FRACTION: usize = 8; // 1/N (smaller number leads to bigger allocations) const DEFAULT_MIN_BLOCK_SIZE: usize = 1 << 10; // 1 KiB diff --git a/sub_crates/oct32norm/benches/bench.rs b/sub_crates/oct32norm/benches/bench.rs index d0d3133..18a6940 100644 --- a/sub_crates/oct32norm/benches/bench.rs +++ b/sub_crates/oct32norm/benches/bench.rs @@ -1,9 +1,4 @@ -#[macro_use] -extern crate bencher; -extern crate oct32norm; -extern crate rand; - -use bencher::{black_box, Bencher}; +use bencher::{benchmark_group, benchmark_main, black_box, Bencher}; use oct32norm::{decode, encode}; use rand::{rngs::SmallRng, FromEntropy, Rng}; diff --git a/sub_crates/sobol/src/lib.rs b/sub_crates/sobol/src/lib.rs index c615306..9a7c5f4 100644 --- a/sub_crates/sobol/src/lib.rs +++ b/sub_crates/sobol/src/lib.rs @@ -22,8 +22,7 @@ mod matrices; -pub use crate::matrices::NUM_DIMENSIONS; -use crate::matrices::{MATRICES, SIZE}; +pub use crate::matrices::{MATRICES, NUM_DIMENSIONS, SIZE}; /// Compute one component of the Sobol'-sequence, where the component /// corresponds to the dimension parameter, and the index specifies diff --git a/sub_crates/spectra_xyz/src/lib.rs b/sub_crates/spectra_xyz/src/lib.rs index 43689c1..3d0ab76 100644 --- a/sub_crates/spectra_xyz/src/lib.rs +++ b/sub_crates/spectra_xyz/src/lib.rs @@ -4,10 +4,9 @@ #![allow(clippy::useless_let_if_seq)] #![allow(clippy::cyclomatic_complexity)] -extern crate float4; +use std::f32; use float4::Float4; -use std::f32; mod spectra_tables; diff --git a/sub_crates/trifloat/benches/bench.rs b/sub_crates/trifloat/benches/bench.rs index 5cef120..e9ca5b5 100644 --- a/sub_crates/trifloat/benches/bench.rs +++ b/sub_crates/trifloat/benches/bench.rs @@ -1,9 +1,4 @@ -#[macro_use] -extern crate bencher; -extern crate rand; -extern crate trifloat; - -use bencher::{black_box, Bencher}; +use bencher::{benchmark_group, benchmark_main, black_box, Bencher}; use rand::{rngs::SmallRng, FromEntropy, Rng}; use trifloat::{decode, encode};