-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27f1983
commit 2c51884
Showing
2 changed files
with
43 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use deku::{bitvec::BitView, container, ctx::Limit, prelude::*, DekuRead, DekuWrite}; | ||
use std::io::Write; | ||
|
||
#[derive(Debug, DekuRead, DekuWrite)] | ||
struct Test { | ||
pub a: u64, | ||
pub b: u64, | ||
pub c: u64, | ||
} | ||
|
||
fn main() { | ||
let input: Vec<_> = (0..10_0000) | ||
.map(|i| Test { | ||
a: i, | ||
b: i + 1, | ||
c: i + 2, | ||
}) | ||
.collect(); | ||
let custom: Vec<u8> = input | ||
.iter() | ||
.flat_map(|x| x.to_bytes().unwrap().into_iter()) | ||
.collect(); | ||
let mut container = Container::new(std::io::Cursor::new(custom.clone())); | ||
let ret = <Vec<Test> as DekuRead<Limit<_, _>>>::from_reader( | ||
&mut container, | ||
Limit::new_count(10_0000), | ||
); | ||
|
||
println!("{:?}", ret); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters