pub struct View<G>where
G: GenericNode,{ /* private fields */ }
Expand description
Represents an UI view. Usually constructed using the view!
macro or using the builder API.
Example
let my_view: View<G> = view! { cx,
div {
p { "A view." }
}
};
Implementations
sourceimpl<G> View<G>where
G: GenericNode,
impl<G> View<G>where
G: GenericNode,
sourcepub fn new_dyn_scoped<'a>(
cx: BoundedScope<'a, 'a>,
f: impl FnMut(BoundedScope<'_, 'a>) -> View<G> + 'a
) -> View<G>
pub fn new_dyn_scoped<'a>(
cx: BoundedScope<'a, 'a>,
f: impl FnMut(BoundedScope<'_, 'a>) -> View<G> + 'a
) -> View<G>
sourcepub fn empty() -> View<G>
pub fn empty() -> View<G>
Create a new View
with a blank marker node
Note that this is different from an empty view fragment. Instead, this is a single marker (dummy) node.
sourcepub fn as_node(&self) -> Option<&G>
pub fn as_node(&self) -> Option<&G>
Try to cast to a GenericNode
, or None
if wrong type.
sourcepub fn as_fragment(&self) -> Option<&[View<G>]>
pub fn as_fragment(&self) -> Option<&[View<G>]>
Try to cast to a slice representing the view fragment, or None
if wrong type.
sourcepub fn as_dyn(&self) -> Option<&RcSignal<View<G>>>
pub fn as_dyn(&self) -> Option<&RcSignal<View<G>>>
Try to cast to the underlying RcSignal
for a dynamic view, or None
if wrong type.
sourcepub fn is_node(&self) -> bool
pub fn is_node(&self) -> bool
Returns true
if the view is a single node. Note that if the view is a fragment containing
only a single child node, this will still return false
.
To check whether the View
only contains a single node, use .flatten().len() == 1
instead.
sourcepub fn is_fragment(&self) -> bool
pub fn is_fragment(&self) -> bool
Returns true
if the view is a view fragment.
Trait Implementations
sourceimpl<G> Clone for View<G>where
G: Clone + GenericNode,
impl<G> Clone for View<G>where
G: Clone + GenericNode,
sourceimpl<G> Debug for View<G>where
G: GenericNode,
impl<G> Debug for View<G>where
G: GenericNode,
sourceimpl<G> Default for View<G>where
G: GenericNode,
impl<G> Default for View<G>where
G: GenericNode,
sourceimpl<'a, G: GenericNode> ElementBuilderOrView<'a, G> for View<G>
impl<'a, G: GenericNode> ElementBuilderOrView<'a, G> for View<G>
sourceimpl<G> IntoView<G> for &View<G>where
G: GenericNode,
impl<G> IntoView<G> for &View<G>where
G: GenericNode,
Auto Trait Implementations
impl<G> !RefUnwindSafe for View<G>
impl<G> !Send for View<G>
impl<G> !Sync for View<G>
impl<G> Unpin for View<G>where
G: Unpin,
impl<G> !UnwindSafe for View<G>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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