diff --git a/rtiow/src/bin/noise_explorer.rs b/rtiow/src/bin/noise_explorer.rs index 448c0d3..85f339d 100644 --- a/rtiow/src/bin/noise_explorer.rs +++ b/rtiow/src/bin/noise_explorer.rs @@ -1,6 +1,5 @@ -#[macro_use] -extern crate askama; extern crate actix_web; +extern crate askama; #[macro_use] extern crate log; extern crate image; @@ -10,7 +9,6 @@ extern crate serde_derive; extern crate serde; extern crate stderrlog; -#[macro_use] extern crate structopt; extern crate rtiow; @@ -41,10 +39,7 @@ use rtiow::texture::Texture; use rtiow::vec3::Vec3; #[derive(Debug, StructOpt)] -#[structopt( - name = "noise_explorer", - about = "CLI for exploring Perlin noise" -)] +#[structopt(name = "noise_explorer", about = "CLI for exploring Perlin noise")] struct Opt { /// HTTP listen address #[structopt(long = "addr", default_value = "0.0.0.0:8889")] @@ -400,7 +395,7 @@ fn noise(np: NoiseParams) -> Result { Ok(HttpResponse::Ok().content_type("image/png").body(buf)) } -#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] +#[allow(clippy::needless_pass_by_value)] fn noise_scale( np: Path, optional: Option>, @@ -414,7 +409,7 @@ fn noise_scale( }) } -#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] +#[allow(clippy::needless_pass_by_value)] fn noise_turbulence( np: Path, optional: Option>, @@ -428,7 +423,7 @@ fn noise_turbulence( }) } -#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))] +#[allow(clippy::needless_pass_by_value)] fn noise_marble( np: Path, optional: Option>, @@ -570,7 +565,8 @@ mod tests { .client( Method::GET, "/noise/lode/32/32/marble/period/1.,2.,3./power/32./size/4/scale/255.", - ).finish() + ) + .finish() .unwrap(); let response = srv.execute(request.send()).unwrap(); assert!(response.status().is_success(), "Response {:?}", response); diff --git a/rtiow/src/bin/tracer.rs b/rtiow/src/bin/tracer.rs index 213e0bf..4612aaf 100644 --- a/rtiow/src/bin/tracer.rs +++ b/rtiow/src/bin/tracer.rs @@ -92,7 +92,7 @@ fn main() -> Result<(), std::io::Error> { runtime.subsec_millis() ); - RUNTIME_COUNTER.set(runtime.as_secs() as f64 + runtime.subsec_nanos() as f64 * 1e-9); + RUNTIME_COUNTER.set(runtime.as_secs() as f64 + f64::from(runtime.subsec_nanos()) * 1e-9); push_metrics(&opt.push_gateway, opt_hash(&opt), &start_time); diff --git a/rtiow/src/scenes/mandelbrot.rs b/rtiow/src/scenes/mandelbrot.rs index 9b590ac..7237222 100644 --- a/rtiow/src/scenes/mandelbrot.rs +++ b/rtiow/src/scenes/mandelbrot.rs @@ -52,7 +52,7 @@ pub fn new(opt: &Opt) -> Scene { Box::new(Sphere::new( Vec3::new(0., 2., 0.), 2.0, - DiffuseLight::new(Mandelbrot::new()), + DiffuseLight::new(Mandelbrot::default()), )), // Earth sized sphere Box::new(Sphere::new( @@ -107,7 +107,7 @@ pub fn new(opt: &Opt) -> Scene { 1., 3., 4., - DiffuseLight::new(Mandelbrot::new()), + DiffuseLight::new(Mandelbrot::default()), )), /* Box::new(Sphere::new( diff --git a/rtiow/src/texture/mandelbrot.rs b/rtiow/src/texture/mandelbrot.rs index 85dfb82..5ba3c55 100644 --- a/rtiow/src/texture/mandelbrot.rs +++ b/rtiow/src/texture/mandelbrot.rs @@ -34,7 +34,7 @@ fn generate_palette(num: usize) -> Vec { let mut rng = rand::thread_rng(); let mut random = || rng.gen_range::(0.0, 0.1); // use golden ratio - let golden_ratio_conjugate = 0.618033988749895; + let golden_ratio_conjugate = 0.618_034; let mut h = random(); (0..num) .map(|_| { @@ -45,8 +45,8 @@ fn generate_palette(num: usize) -> Vec { .collect() } -impl Mandelbrot { - pub fn new() -> Mandelbrot { +impl Default for Mandelbrot { + fn default() -> Self { Mandelbrot { scale: 2.0, palette: generate_palette(10), @@ -68,7 +68,7 @@ impl Texture for Mandelbrot { let xtemp = x * x - y * y + x0; y = 2. * x * y + y0; x = xtemp; - iteration = iteration + 1; + iteration += 1; } if iteration == max_iteration { return Vec3::default();