[−][src]Struct revent::Node
Node containing arbitrary data.
Ensures that no double-mutable borrows exist and allows the contained item to Suspend itself.
Node is fundamentally the same as RefCell, but does one more thing:
it allows suspension of the last emitted node by using its &mut
. Suspending allows the
node to be reborrowed without aliasing.
Implementations
impl<T> Node<T>
[src]
pub fn new(item: T) -> Self
[src]
Create a new node.
pub fn new_with_trace(item: T, trace: impl Fn(usize) + 'static) -> Self
[src]
Create a new node with a tracing function.
The trace function is called with the current indentation value. It can be used to log calls to nodes and see how various nodes call upon other nodes.
Requires the trace
feature to be enabled to actually use the trace
function.
impl<T: ?Sized> Node<T>
[src]
pub fn emit<F: FnOnce(&mut T) -> R, R>(&self, handler: F) -> R
[src]
Acquire a &mut
to the contents of the node and allow it to Suspend itself.
use revent::Node; let node = Node::new(123); node.emit(|x| { *x = 456; println!("{}", x); });
Panics
Panics if the node has already been accessed without being suspended.
use revent::Node; let node = Node::new(123); node.emit(|_| { node.emit(|_| {}); });
The mitigation is to call suspend on the emit
lambda argument.
use revent::{Node, Suspend}; let node = Node::new(123); node.emit(|x| { x.suspend(|| { node.emit(|_| {}); }); });
pub fn ptr_eq(this: &Self, other: &Self) -> bool
[src]
Returns true if two Node
s point to the same allocation.
Trait Implementations
impl<T> Clone for Node<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: ?Sized, U> CoerceUnsized<Node<U>> for Node<T> where
T: Unsize<U>,
U: ?Sized,
[src]
T: Unsize<U>,
U: ?Sized,
Auto Trait Implementations
impl<T> !RefUnwindSafe for Node<T>
impl<T> !Send for Node<T>
impl<T> !Sync for Node<T>
impl<T: ?Sized> Unpin for Node<T>
impl<T> !UnwindSafe for Node<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Suspend for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,