Arena storage pool: Difference between revisions

m
Fix formatting
(Copied implementation from https://github.com/Hoverbear/rust-rosetta)
m (Fix formatting)
Line 599:
drop stemmed_array.</lang>
 
=={{header|ScalaRust}}==
<lang rust>#![feature(rustc_private)]
 
Line 612:
// chunk size is configurable as an argument to TypedArena::with_capacity if necessary.
let arena = TypedArena::new();
 
// The arena crate contains two types of arenas: TypedArena and Arena. Arena is
// reflection-basd and slower, but can allocate objects of any type. TypedArena is faster, and
Line 617 ⟶ 618:
// to allocate an integer, then Rust's compiler knows it is an integer arena.
let v1 = arena.alloc(1i32);
 
// TypedArena returns a mutable reference
let v2 = arena.alloc(3);
*v2 += 38;
println!("{}", *v1 + *v2);
 
// The arena's destructor is called as it goes out of scope, at which point it deallocates
// everything stored within it at once.
Anonymous user