pub fn with_emplacable_for<T, F, R>(val: T, f: F) -> RExpand 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
#![allow(internal_features)] // for `unsized_fn_params`
#![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]);