Skip to content

Commit

Permalink
scroll, scroll_derive: run cargo-fmt on everything
Browse files Browse the repository at this point in the history
  • Loading branch information
m4b committed Jan 25, 2021
1 parent 2dc19d1 commit f3f6a5b
Show file tree
Hide file tree
Showing 14 changed files with 728 additions and 443 deletions.
4 changes: 2 additions & 2 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn bench_parallel_cread_with(b: &mut test::Bencher) {
let nums = vec![0usize; 500_000];
b.iter(|| {
let data = black_box(&vec[..]);
nums.par_iter().for_each(| offset | {
nums.par_iter().for_each(|offset| {
let _: u16 = black_box(data.cread_with(*offset, LE));
});
});
Expand Down Expand Up @@ -123,7 +123,7 @@ fn bench_parallel_pread_with(b: &mut test::Bencher) {
let nums = vec![0usize; 500_000];
b.iter(|| {
let data = black_box(&vec[..]);
nums.par_iter().for_each(| offset | {
nums.par_iter().for_each(|offset| {
let _: Result<u16, _> = black_box(data.pread_with(*offset, LE));
});
});
Expand Down
7 changes: 3 additions & 4 deletions examples/data_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ struct Data<'a> {

impl<'a> ctx::TryFromCtx<'a, Endian> for Data<'a> {
type Error = scroll::Error;
fn try_from_ctx (src: &'a [u8], endian: Endian)
-> Result<(Self, usize), Self::Error> {
fn try_from_ctx(src: &'a [u8], endian: Endian) -> Result<(Self, usize), Self::Error> {
let name = src.pread::<&'a str>(0)?;
let id = src.pread_with(name.len()+1, endian)?;
Ok((Data { name: name, id: id }, name.len()+4))
let id = src.pread_with(name.len() + 1, endian)?;
Ok((Data { name: name, id: id }, name.len() + 4))
}
}

Expand Down
10 changes: 6 additions & 4 deletions scroll_derive/examples/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use scroll_derive::{Pread, Pwrite, IOread, IOwrite, SizeWith};
use scroll_derive::{IOread, IOwrite, Pread, Pwrite, SizeWith};

#[derive(Debug, PartialEq, Pread, Pwrite, IOread, IOwrite, SizeWith)]
#[repr(C)]
Expand All @@ -8,10 +8,12 @@ struct Data {
arr: [u16; 2],
}

use scroll::{Pread, Pwrite, Cread, LE};
use scroll::{Cread, Pread, Pwrite, LE};

fn main () {
let bytes = [0xefu8, 0xbe, 0xad, 0xde, 0, 0, 0, 0, 0, 0, 224, 63, 0xad, 0xde, 0xef, 0xbe];
fn main() {
let bytes = [
0xefu8, 0xbe, 0xad, 0xde, 0, 0, 0, 0, 0, 0, 224, 63, 0xad, 0xde, 0xef, 0xbe,
];
let data: Data = bytes.pread_with(0, LE).unwrap();
println!("data: {:?}", &data);
assert_eq!(data.id, 0xdeadbeefu32);
Expand Down
Loading

0 comments on commit f3f6a5b

Please sign in to comment.