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 actix_web;
|
||||||
|
extern crate askama;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
extern crate image;
|
extern crate image;
|
||||||
@ -10,7 +9,6 @@ extern crate serde_derive;
|
|||||||
extern crate serde;
|
extern crate serde;
|
||||||
extern crate stderrlog;
|
extern crate stderrlog;
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate structopt;
|
extern crate structopt;
|
||||||
|
|
||||||
extern crate rtiow;
|
extern crate rtiow;
|
||||||
@ -41,10 +39,7 @@ use rtiow::texture::Texture;
|
|||||||
use rtiow::vec3::Vec3;
|
use rtiow::vec3::Vec3;
|
||||||
|
|
||||||
#[derive(Debug, StructOpt)]
|
#[derive(Debug, StructOpt)]
|
||||||
#[structopt(
|
#[structopt(name = "noise_explorer", about = "CLI for exploring Perlin noise")]
|
||||||
name = "noise_explorer",
|
|
||||||
about = "CLI for exploring Perlin noise"
|
|
||||||
)]
|
|
||||||
struct Opt {
|
struct Opt {
|
||||||
/// HTTP listen address
|
/// HTTP listen address
|
||||||
#[structopt(long = "addr", default_value = "0.0.0.0:8889")]
|
#[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))
|
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(
|
fn noise_scale(
|
||||||
np: Path<NoiseParamsScale>,
|
np: Path<NoiseParamsScale>,
|
||||||
optional: Option<Query<OptionalParams>>,
|
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(
|
fn noise_turbulence(
|
||||||
np: Path<NoiseParamsTurbulence>,
|
np: Path<NoiseParamsTurbulence>,
|
||||||
optional: Option<Query<OptionalParams>>,
|
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(
|
fn noise_marble(
|
||||||
np: Path<NoiseParamsMarble>,
|
np: Path<NoiseParamsMarble>,
|
||||||
optional: Option<Query<OptionalParams>>,
|
optional: Option<Query<OptionalParams>>,
|
||||||
@ -570,7 +565,8 @@ mod tests {
|
|||||||
.client(
|
.client(
|
||||||
Method::GET,
|
Method::GET,
|
||||||
"/noise/lode/32/32/marble/period/1.,2.,3./power/32./size/4/scale/255.",
|
"/noise/lode/32/32/marble/period/1.,2.,3./power/32./size/4/scale/255.",
|
||||||
).finish()
|
)
|
||||||
|
.finish()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let response = srv.execute(request.send()).unwrap();
|
let response = srv.execute(request.send()).unwrap();
|
||||||
assert!(response.status().is_success(), "Response {:?}", response);
|
assert!(response.status().is_success(), "Response {:?}", response);
|
||||||
|
|||||||
@ -92,7 +92,7 @@ fn main() -> Result<(), std::io::Error> {
|
|||||||
runtime.subsec_millis()
|
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);
|
push_metrics(&opt.push_gateway, opt_hash(&opt), &start_time);
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ pub fn new(opt: &Opt) -> Scene {
|
|||||||
Box::new(Sphere::new(
|
Box::new(Sphere::new(
|
||||||
Vec3::new(0., 2., 0.),
|
Vec3::new(0., 2., 0.),
|
||||||
2.0,
|
2.0,
|
||||||
DiffuseLight::new(Mandelbrot::new()),
|
DiffuseLight::new(Mandelbrot::default()),
|
||||||
)),
|
)),
|
||||||
// Earth sized sphere
|
// Earth sized sphere
|
||||||
Box::new(Sphere::new(
|
Box::new(Sphere::new(
|
||||||
@ -107,7 +107,7 @@ pub fn new(opt: &Opt) -> Scene {
|
|||||||
1.,
|
1.,
|
||||||
3.,
|
3.,
|
||||||
4.,
|
4.,
|
||||||
DiffuseLight::new(Mandelbrot::new()),
|
DiffuseLight::new(Mandelbrot::default()),
|
||||||
)),
|
)),
|
||||||
/*
|
/*
|
||||||
Box::new(Sphere::new(
|
Box::new(Sphere::new(
|
||||||
|
|||||||
@ -34,7 +34,7 @@ fn generate_palette(num: usize) -> Vec<Vec3> {
|
|||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
let mut random = || rng.gen_range::<f32>(0.0, 0.1);
|
let mut random = || rng.gen_range::<f32>(0.0, 0.1);
|
||||||
// use golden ratio
|
// use golden ratio
|
||||||
let golden_ratio_conjugate = 0.618033988749895;
|
let golden_ratio_conjugate = 0.618_034;
|
||||||
let mut h = random();
|
let mut h = random();
|
||||||
(0..num)
|
(0..num)
|
||||||
.map(|_| {
|
.map(|_| {
|
||||||
@ -45,8 +45,8 @@ fn generate_palette(num: usize) -> Vec<Vec3> {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mandelbrot {
|
impl Default for Mandelbrot {
|
||||||
pub fn new() -> Mandelbrot {
|
fn default() -> Self {
|
||||||
Mandelbrot {
|
Mandelbrot {
|
||||||
scale: 2.0,
|
scale: 2.0,
|
||||||
palette: generate_palette(10),
|
palette: generate_palette(10),
|
||||||
@ -68,7 +68,7 @@ impl Texture for Mandelbrot {
|
|||||||
let xtemp = x * x - y * y + x0;
|
let xtemp = x * x - y * y + x0;
|
||||||
y = 2. * x * y + y0;
|
y = 2. * x * y + y0;
|
||||||
x = xtemp;
|
x = xtemp;
|
||||||
iteration = iteration + 1;
|
iteration += 1;
|
||||||
}
|
}
|
||||||
if iteration == max_iteration {
|
if iteration == max_iteration {
|
||||||
return Vec3::default();
|
return Vec3::default();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user