pub struct Relocator<Binder = ()> {
pub(super) lazy_binder: Binder,
pub(super) run_init: bool,
}
impl<Binder> Clone for Relocator<Binder>
where
Binder: Clone,
{
#[inline]
fn clone(&self) -> Self {
Self {
lazy_binder: self.lazy_binder.clone(),
run_init: self.run_init,
}
}
}
impl<Binder> Copy for Relocator<Binder> where Binder: Copy {}
impl Relocator<()> {
#[inline]
pub const fn new() -> Self {
Self {
lazy_binder: (),
run_init: true,
}
}
}
impl Default for Relocator<()> {
#[inline]
fn default() -> Self {
Self::new()
}
}
impl<Binder> Relocator<Binder> {
pub const fn lazy_binder<NewBinder>(self, binder: NewBinder) -> Relocator<NewBinder>
where
Binder: Copy,
{
let _ = self.lazy_binder;
Relocator {
lazy_binder: binder,
run_init: self.run_init,
}
}
#[inline]
pub const fn defer_init(mut self) -> Self {
self.run_init = false;
self
}
}