pub struct WatchContext<'ctx, O: ?Sized = DefaultOwner> { /* private fields */ }

Implementations

Create a new WatchContext

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

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.