allow public uses of structs; add sample program

This commit is contained in:
2020-04-12 17:13:08 +01:00
parent fd4a682ade
commit bef39f9b8b
15 changed files with 132 additions and 61 deletions

View File

@@ -2,7 +2,7 @@ use crate::mock;
#[derive(Debug, Eq, PartialEq)]
pub struct Image {
pub(crate) pixels: Vec<u8>, // 64 for SD, 256 for HD
pub pixels: Vec<u32>, // 64 for SD, 256 for HD
}
impl From<String> for Image {
@@ -12,8 +12,8 @@ impl From<String> for Image {
let pixels: Vec<&str> = string.split("").collect();
// the above seems to add an extra "" at the start and end of the vec, so strip them below
let pixels = &pixels[1..(pixels.len() - 1)];
let pixels: Vec<u8> = pixels.iter().map(|&pixel| {
pixel.parse::<u8>().unwrap()
let pixels: Vec<u32> = pixels.iter().map(|&pixel| {
pixel.parse::<u32>().unwrap()
}).collect();
Image { pixels }