Clippy + fmt.
This commit is contained in:
45
src/main.rs
45
src/main.rs
@@ -2,6 +2,7 @@ extern crate getopts;
|
|||||||
extern crate rand;
|
extern crate rand;
|
||||||
extern crate ansi_term;
|
extern crate ansi_term;
|
||||||
|
|
||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
@@ -11,6 +12,7 @@ use getopts::Options;
|
|||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
use ansi_term::Colour::RGB;
|
use ansi_term::Colour::RGB;
|
||||||
|
|
||||||
|
|
||||||
fn print_usage(program: &str, opts: Options) {
|
fn print_usage(program: &str, opts: Options) {
|
||||||
let brief = format!("Usage: {} [OPTION]... [FILE]...", program);
|
let brief = format!("Usage: {} [OPTION]... [FILE]...", program);
|
||||||
|
|
||||||
@@ -28,10 +30,10 @@ fn main() {
|
|||||||
opts.optopt("S", "seed", "Rainbow seed, 0 = random", "<i>");
|
opts.optopt("S", "seed", "Rainbow seed, 0 = random", "<i>");
|
||||||
opts.optflag("h", "help", "Show this message");
|
opts.optflag("h", "help", "Show this message");
|
||||||
|
|
||||||
// @todo do not panic!
|
// TODO Do not panic!
|
||||||
let matches = match opts.parse(&args[1..]) {
|
let matches = match opts.parse(&args[1..]) {
|
||||||
Ok(m) => { m }
|
Ok(m) => m,
|
||||||
Err(f) => { panic!(f.to_string()) }
|
Err(f) => panic!(f.to_string()),
|
||||||
};
|
};
|
||||||
|
|
||||||
// print usage?
|
// print usage?
|
||||||
@@ -42,47 +44,44 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get spread.
|
// get spread.
|
||||||
// @todo this is nasty... fix this.
|
// TODO this is nasty... fix this.
|
||||||
let spread: f32 = match matches.opt_default("spread", "3.0") {
|
let spread: f32 = match matches.opt_default("spread", "3.0") {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
match s.parse() {
|
match s.parse() {
|
||||||
Ok(0.0) => 3.0,
|
Ok(n) if n != 0.0 => n,
|
||||||
Ok(n) => n,
|
_ => 3.0,
|
||||||
_ => 3.0
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => 3.0
|
None => 3.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// get freq.
|
// get freq.
|
||||||
// @todo this is nasty... fix this.
|
// TODO this is nasty... fix this.
|
||||||
let freq: f32 = match matches.opt_default("freq", "0.1") {
|
let freq: f32 = match matches.opt_default("freq", "0.1") {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
match s.parse() {
|
match s.parse() {
|
||||||
Ok(0.0) => 0.1,
|
Ok(n) if n != 0.0 => n,
|
||||||
Ok(n) => n,
|
_ => 0.1,
|
||||||
_ => 0.1
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => 0.1
|
None => 0.1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// get seed.
|
// get seed.
|
||||||
// @todo this is nasty... fix this.
|
// TODO this is nasty... fix this.
|
||||||
let mut seed: i32 = match matches.opt_default("seed", "0") {
|
let mut seed: i32 = match matches.opt_default("seed", "0") {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
match s.parse() {
|
match s.parse() {
|
||||||
Ok(0) => thread_rng().gen_range(0, 256),
|
Ok(n) if n != 0 => n,
|
||||||
Ok(n) => n,
|
_ => thread_rng().gen_range(0, 256),
|
||||||
_ => thread_rng().gen_range(0, 256)
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => thread_rng().gen_range(0, 256)
|
None => thread_rng().gen_range(0, 256),
|
||||||
};
|
};
|
||||||
|
|
||||||
let stdin = io::stdin();
|
let stdin = io::stdin();
|
||||||
|
|
||||||
// @todo I want to use chars() instead, but it's unstable right now :(
|
// TODO I want to use chars() instead, but it's unstable right now :(
|
||||||
for line in stdin.lock().lines() {
|
for line in stdin.lock().lines() {
|
||||||
seed += 1;
|
seed += 1;
|
||||||
|
|
||||||
@@ -96,7 +95,7 @@ fn main() {
|
|||||||
print!("{}", RGB(red, green, blue).paint(c.to_string()));
|
print!("{}", RGB(red, green, blue).paint(c.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
print!("\n");
|
println!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user