Function r3_core::bind::fn_bind_map
source · pub const fn fn_bind_map<FnBind, Mapper>(
inner: FnBind,
mapper: Mapper
) -> FnBindMap<FnBind, Mapper>
Expand description
Apply a function to an impl
FnBind
<_>
’s output.
Example
#![feature(const_trait_impl)]
#![feature(const_mut_refs)]
use core::cell::UnsafeCell;
use r3_core::{kernel::{cfg, traits}, bind::{Bind, FnBind, fn_bind_map}};
/// Like `r3::bind::bind` but wraps the output in `UnsafeCell`
const fn unsafe_cell_bind<'pool, C, Binder, Func, T>(
cfg: &mut cfg::Cfg<'pool, C>,
binder: Binder,
func: Func,
) -> Bind<'pool, C::System, UnsafeCell<T>>
where
C: ~const traits::CfgBase,
C::System: traits::KernelBase + traits::KernelStatic,
Func: ~const FnBind<Binder, Output = T>,
T: 'static,
{
Bind::define()
// Apply `UnsafeCell::new` on `func`'s output
.init_with_bind(binder, fn_bind_map(func, UnsafeCell::new))
.finish(cfg)
}