allow public uses of structs; add sample program
This commit is contained in:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user