Struct dioxus_core::prelude::LazyNodes
source · [−]pub struct LazyNodes<'a, 'b> { /* private fields */ }
Expand description
A concrete type provider for closures that build VNode structures.
This struct wraps lazy structs that build VNode trees Normally, we cannot perform a blanket implementation over closures, but if we wrap the closure in a concrete type, we can maintain separate implementations of IntoVNode.
LazyNodes::new(|f| f.element("div", [], [], [] None))
Implementations
sourceimpl<'a, 'b> LazyNodes<'a, 'b>
impl<'a, 'b> LazyNodes<'a, 'b>
sourcepub fn new(val: impl FnOnce(NodeFactory<'a>) -> VNode<'a> + 'b) -> Self
pub fn new(val: impl FnOnce(NodeFactory<'a>) -> VNode<'a> + 'b) -> Self
Create a new LazyNodes closure, optimistically placing it onto the stack.
If the closure cannot fit into the stack allocation (16 bytes), then it is placed on the heap. Most closures will fit into the stack, and is the most optimal way to use the creation function.
sourcepub fn new_boxed<F>(_val: F) -> Self where
F: FnOnce(NodeFactory<'a>) -> VNode<'a> + 'b,
pub fn new_boxed<F>(_val: F) -> Self where
F: FnOnce(NodeFactory<'a>) -> VNode<'a> + 'b,
Create a new LazyNodes closure, but force it onto the heap.
sourcepub fn call(self, f: NodeFactory<'a>) -> VNode<'a>
pub fn call(self, f: NodeFactory<'a>) -> VNode<'a>
Call the closure with the given factory to produce real VNodes.
let f = LazyNodes::new(move |f| f.element("div", [], [], [] None));
let fac = NodeFactory::new(&cx);
let node = f.call(cac);
Trait Implementations
sourceimpl<'a, 'b> IntoIterator for LazyNodes<'a, 'b>
impl<'a, 'b> IntoIterator for LazyNodes<'a, 'b>
sourceimpl<'a, 'b> IntoVNode<'a> for LazyNodes<'a, 'b>
impl<'a, 'b> IntoVNode<'a> for LazyNodes<'a, 'b>
sourcefn into_vnode(self, cx: NodeFactory<'a>) -> VNode<'a>
fn into_vnode(self, cx: NodeFactory<'a>) -> VNode<'a>
Convert this into a VNode
, using the NodeFactory
as a source of allocation
Auto Trait Implementations
impl<'a, 'b> !RefUnwindSafe for LazyNodes<'a, 'b>
impl<'a, 'b> !Send for LazyNodes<'a, 'b>
impl<'a, 'b> !Sync for LazyNodes<'a, 'b>
impl<'a, 'b> Unpin for LazyNodes<'a, 'b>
impl<'a, 'b> !UnwindSafe for LazyNodes<'a, 'b>
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