Function emplacable::with_emplacable_for
source · pub fn with_emplacable_for<T, F, R>(val: T, f: F) -> R
Expand description
Accepts a possibly-unsized value as a first argument,
turns it into an Emplacable
, and passes the emplacer to
the given closure.
If T
is sized, you can use Into::into
instead.
§Example
#![feature(allocator_api, ptr_metadata, unsized_fn_params)]
use emplacable::{box_new_with, unsize, with_emplacable_for};
let b = with_emplacable_for(unsize!([23_i32, 4, 32], ([i32; 3]) -> [i32]), |e| {
box_new_with(e)
});
assert_eq!(&*b, &[23_i32, 4, 32]);