pub trait UnzipBind {
type Target;
// Required method
fn unzip(self) -> Self::Target;
}
Expand description
An extension trait for destructing Bind
<_, (T0, T1, ...)>
into
individual bindings (Bind<_, T0>, Bind<_, T1>, ...)
.
Temporary Restrictions: Currently the destruction makes the original value completely inaccessible owing to it being implemented by
BindTakeMut
. Essentially, this divides the timeline into two parts: the first part where only the pre-destruction binding (Bind<_, (T0, T1, ...)>
) can be borrowed and the second part where only the post-destruction bindings (Bind<_, T0>, Bind<_, T1>, ...
) can be borrowed.
Examples
#![feature(const_trait_impl)]
#![feature(const_mut_refs)]
use r3_core::{bind::Bind, kernel::{Cfg, traits}, prelude::*};
const fn configure_app<C>(cfg: &mut Cfg<C>)
where
C: ~const traits::CfgStatic,
{
let values = Bind::define().init(|| (12, 34)).finish(cfg);
let (value0, value1) = values.unzip();
Bind::define()
.init_with_bind((value0.take_mut(),), |x: &mut i32| assert_eq!(*x, 12))
.unpure()
.finish(cfg);
Bind::define()
.init_with_bind((value1.take_mut(),), |x: &mut i32| assert_eq!(*x, 34))
.unpure()
.finish(cfg);
}
Stability
This trait is covered by the application-side API stability guarantee. External implementation of this trait is not allowed.