Struct drying_paint::WatchContext
source · [−]pub struct WatchContext<'ctx, O: ?Sized = DefaultOwner> { /* private fields */ }Implementations
sourceimpl<'ctx, O> WatchContext<'ctx, O>
impl<'ctx, O> WatchContext<'ctx, O>
pub fn from_owner(owner: O) -> Self
sourceimpl<'ctx, O: Default> WatchContext<'ctx, O>
impl<'ctx, O: Default> WatchContext<'ctx, O>
sourceimpl<'ctx, O: ?Sized> WatchContext<'ctx, O>
impl<'ctx, O: ?Sized> WatchContext<'ctx, O>
pub fn add_watch<F>(&mut self, func: F) where
F: 'ctx + Fn(&mut O, WatchArg<'_, 'ctx, O>),
pub fn add_watch_might_add_watcher<F, T>(&mut self, func: F) where
F: 'ctx + Fn(&mut O, WatchArg<'_, 'ctx, O>) -> Option<T>,
T: 'ctx + WatcherHolder<'ctx, O>,
T::Content: Watcher<'ctx, O>,
pub fn add_watch_raw<F>(&mut self, debug_name: &'static str, f: F) where
F: 'ctx + Fn(RawWatchArg<'_, 'ctx, O>),
pub fn add_watcher<T>(&mut self, holder: &T) where
T: 'ctx + ?Sized + WatcherHolder<'ctx, O>,
T::Content: Watcher<'ctx, O>,
pub fn owner(&mut self) -> &mut O
pub fn update(&mut self)
sourcepub fn set_frame_limit(&mut self, value: Option<usize>)
pub fn set_frame_limit(&mut self, value: Option<usize>)
Set the number of cycles this watch context will execute before panicking. This is useful for catching bugs involving recursive watches. None indicates no limit. The default behaviour is to provide a high value for debug builds and no limit for release builds.
Examples
ⓘ
#[derive(Default)]
struct KeepBalanced {
left: Watched<i32>,
right: Watched<i32>,
}
impl Watcher<'static> for KeepBalanced {
fn init(mut init: impl WatcherInit<'static, Self>) {
init.watch(|root| {
*root.left = *root.right;
});
init.watch(|root| {
*root.right = *root.left;
});
}
}
let keep_balanced = Rc::new(RefCell::new(KeepBalanced {
left: Watched::new(7),
right: Watched::new(7),
}));
let weak = Rc::downgrade(&keep_balanced);
let mut ctx = WatchContext::new();
ctx.set_frame_limit(Some(1000));
ctx.add_watcher(&weak);
ctx.update();Trait Implementations
Auto Trait Implementations
impl<'ctx, O = DefaultOwner> !RefUnwindSafe for WatchContext<'ctx, O>
impl<'ctx, O = DefaultOwner> !Send for WatchContext<'ctx, O>
impl<'ctx, O = DefaultOwner> !Sync for WatchContext<'ctx, O>
impl<'ctx, O: ?Sized> Unpin for WatchContext<'ctx, O> where
O: Unpin,
impl<'ctx, O = DefaultOwner> !UnwindSafe for WatchContext<'ctx, O>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more