simplify
This commit is contained in:
parent
4238ea033a
commit
6fe46a1085
|
@ -17,11 +17,10 @@ impl From<&str> for Colour {
|
||||||
|
|
||||||
impl From<Vec<u8>> for Colour {
|
impl From<Vec<u8>> for Colour {
|
||||||
fn from(colours: Vec<u8>) -> Self {
|
fn from(colours: Vec<u8>) -> Self {
|
||||||
const ZERO: u8 = 0;
|
|
||||||
Colour {
|
Colour {
|
||||||
red: *colours.get(0).unwrap_or(&ZERO),
|
red: *colours.get(0).unwrap_or(&0),
|
||||||
green: *colours.get(1).unwrap_or(&ZERO),
|
green: *colours.get(1).unwrap_or(&0),
|
||||||
blue: *colours.get(2).unwrap_or(&ZERO),
|
blue: *colours.get(2).unwrap_or(&0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,9 @@ impl Image {
|
||||||
let name = path.file_stem().unwrap().to_str().unwrap().into();
|
let name = path.file_stem().unwrap().to_str().unwrap().into();
|
||||||
let mut pixels: Vec<u8> = Vec::new();
|
let mut pixels: Vec<u8> = Vec::new();
|
||||||
|
|
||||||
for line in read_to_string(&path).unwrap().lines() {
|
// todo .matches [0..3] instead of replacing whitespace?
|
||||||
for char in line.chars() {
|
for char in read_to_string(&path).unwrap().replace('\n', "").chars() {
|
||||||
pixels.push(char.to_string().parse().unwrap());
|
pixels.push(char.to_string().parse().unwrap());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Self { name, pixels }
|
Self { name, pixels }
|
||||||
|
|
Loading…
Reference in New Issue