Solve challenge 12.

This commit is contained in:
2022-06-17 18:08:34 -04:00
parent f9ddf4cccd
commit 961f75bb7d
3 changed files with 48 additions and 39 deletions

View File

@@ -16,8 +16,8 @@ impl Bytes {
String::from(std::str::from_utf8(&v).unwrap())
}
pub fn first_block(&self, length: usize) -> Bytes {
Bytes(self.0[0..length].to_vec())
pub fn get_block(&self, block_index: usize, block_size: usize) -> Bytes {
Bytes(self.0[(block_index * block_size)..(block_index + 1) * block_size].to_vec())
}
pub fn random(length: usize) -> Bytes {