Skip to content

Commit

Permalink
Run rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
thomcc committed Jan 9, 2023
1 parent 17738fb commit 400b56b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
18 changes: 7 additions & 11 deletions benches/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
extern crate criterion;
extern crate typed_arena;

use criterion::{Criterion, BenchmarkId};
use criterion::{BenchmarkId, Criterion};

#[derive(Default)]
struct Small(usize);
Expand All @@ -23,16 +23,12 @@ fn criterion_benchmark(c: &mut Criterion) {
for n in 1..5 {
let n = n * 1000;
group.throughput(criterion::Throughput::Elements(n as u64));
group.bench_with_input(
BenchmarkId::new("allocate-small", n),
&n,
|b, &n| b.iter(|| allocate::<Small>(n)),
);
group.bench_with_input(
BenchmarkId::new("allocate-big", n),
&n,
|b, &n| b.iter(|| allocate::<Big>(n)),
);
group.bench_with_input(BenchmarkId::new("allocate-small", n), &n, |b, &n| {
b.iter(|| allocate::<Small>(n))
});
group.bench_with_input(BenchmarkId::new("allocate-big", n), &n, |b, &n| {
b.iter(|| allocate::<Big>(n))
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl<T> Arena<T> {
let next_item_index = chunks.current.len();

unsafe {
// Go through pointers, to make sure we never create a reference to uninitialized T.
// Go through pointers, to make sure we never create a reference to uninitialized T.
let start = chunks.current.as_mut_ptr().offset(next_item_index as isize);
let start_uninit = start as *mut MaybeUninit<T>;
slice::from_raw_parts_mut(start_uninit, len) as *mut _
Expand Down
8 changes: 6 additions & 2 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ fn test_alloc_uninitialized() {
for i in 0..LIMIT {
let slice = arena.alloc_uninitialized(i);
for (j, elem) in slice.iter_mut().enumerate() {
ptr::write(elem.as_mut_ptr(), Node(None, j as u32, DropTracker(&drop_counter)));
ptr::write(
elem.as_mut_ptr(),
Node(None, j as u32, DropTracker(&drop_counter)),
);
}
assert_eq!(drop_counter.get(), 0);
}
Expand Down Expand Up @@ -170,7 +173,8 @@ fn alloc_uninitialized_with_panic() {
panic!("To drop the arena");
// If it didn't panic, we would continue by initializing the second one and confirming by
// .alloc_uninitialized();
})).unwrap_err();
}))
.unwrap_err();
assert!(reached_first_init);
}

Expand Down

0 comments on commit 400b56b

Please sign in to comment.