Format Rust code using rustfmt

This commit is contained in:
github-actions[bot]
2020-04-18 15:58:30 +00:00
committed by GitHub
parent 9a5c4df2b1
commit cba6c16414
18 changed files with 956 additions and 394 deletions

View File

@@ -9,9 +9,9 @@ impl From<String> for Colour {
fn from(string: String) -> Colour {
let values: Vec<&str> = string.split(',').collect();
let red: u8 = values[0].parse().unwrap_or(0);
let red: u8 = values[0].parse().unwrap_or(0);
let green: u8 = values[1].parse().unwrap_or(0);
let blue: u8 = values[2].parse().unwrap_or(0);
let blue: u8 = values[2].parse().unwrap_or(0);
Colour { red, green, blue }
}
@@ -24,19 +24,27 @@ impl ToString for Colour {
}
}
#[test]
fn test_colour_from_string() {
assert_eq!(
Colour::from("0,255,0".to_string()),
Colour { red: 0, green: 255, blue: 0 }
Colour {
red: 0,
green: 255,
blue: 0
}
);
}
#[test]
fn test_colour_to_string() {
assert_eq!(
Colour { red: 22, green: 33, blue: 44 }.to_string(),
Colour {
red: 22,
green: 33,
blue: 44
}
.to_string(),
"22,33,44".to_string()
);
}