Fix clippy lint.
This commit is contained in:
parent
cdbaa928c2
commit
e64e6af085
@ -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<HttpResponse> {
|
||||
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<NoiseParamsScale>,
|
||||
optional: Option<Query<OptionalParams>>,
|
||||
@ -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<NoiseParamsTurbulence>,
|
||||
optional: Option<Query<OptionalParams>>,
|
||||
@ -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<NoiseParamsMarble>,
|
||||
optional: Option<Query<OptionalParams>>,
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -34,7 +34,7 @@ fn generate_palette(num: usize) -> Vec<Vec3> {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut random = || rng.gen_range::<f32>(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<Vec3> {
|
||||
.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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user