>>102049842
Chapter 1: Chunk Types
>https://jrdngr.github.io/pngme_book/chapter_1.html
Requirements:
1. Copy the unit tests below and paste them at the bottom of your chunk_type.rs file.
2. Write a ChunkType struct with your implementation of PNG chunk types.
3. Implement TryFrom<[u8; 4]> for your ChunkType.
The first test is:
#[test]
pub fn test_chunk_type_from_bytes() {
let expected = [82, 117, 83, 116];
let actual = ChunkType::try_from([82, 117, 83, 116]).unwrap();
assert_eq!(expected, actual.bytes());
}
Chapter 1 hints:
>https://jrdngr.github.io/pngme_book/hints/chapter_1_hints.html
This includes the following code block:
impl TryFrom<[u8; 4]> for ChunkType {
type Error = Error;
fn try_from(bytes: [u8; 4]) -> Result<Self> {
todo!()
}
}
First of all, I am getting IDE warnings saying I should add 'dyn' keyword to the Error line and add missing generic argument to the try_from signature.
On the other hand, what am I even supposed to do if, in the test, it expects the same int vector as the one passed to ChunkType::tryfrom()? Do I just return the same shit like the following?
impl TryFrom<[u8; 4]> for ChunkType {
type Error = Error;
fn try_from(value: [u8; 4]) -> Result<Self> {
Ok(ChunkType { chunk_type: value })
}
}
This makes me feel stupid