Struct zng::widget::builder::PropertyInputTypes
source · pub struct PropertyInputTypes<Tuple>(/* private fields */);
Expand description
Represents the strong types of each input of a property.
§Examples
The example uses property_input_types!
to collect the types and compares it to a manually generated types. Note
that the type is a tuple even if there is only one input.
#[property(CONTEXT)]
pub fn foo(child: impl UiNode, bar: impl IntoVar<bool>) -> impl UiNode {
}
assert_eq!(
property_input_types!(foo).type_id(),
PropertyInputTypes::<(BoxedVar<bool>,)>::unit().type_id(),
);
You can use the collected types in advanced code generation, such as attribute proc-macros targeting property assigns in widgets.
The next example demonstrates a trait that uses auto-deref to convert a trait bound to a bool
:
#[property(CONTEXT)]
pub fn foo(child: impl UiNode, bar: impl IntoVar<bool>) -> impl UiNode {
}
trait SingleBoolVar {
fn is_single_bool_var(self) -> bool;
}
// match
impl<'a, V: Var<bool>> SingleBoolVar for &'a PropertyInputTypes<(V,)> {
fn is_single_bool_var(self) -> bool {
true
}
}
// fallback impl
impl<T: Send + 'static> SingleBoolVar for PropertyInputTypes<T> {
fn is_single_bool_var(self) -> bool {
false
}
}
assert!((&property_input_types!(foo)).is_single_bool_var());
Learn more about how this trick works and limitations here.
Implementations§
source§impl<Tuple> PropertyInputTypes<Tuple>
impl<Tuple> PropertyInputTypes<Tuple>
sourcepub const fn unit() -> PropertyInputTypes<Tuple>
pub const fn unit() -> PropertyInputTypes<Tuple>
Unit value.
Trait Implementations§
source§impl<Tuple> Clone for PropertyInputTypes<Tuple>
impl<Tuple> Clone for PropertyInputTypes<Tuple>
source§fn clone(&self) -> PropertyInputTypes<Tuple>
fn clone(&self) -> PropertyInputTypes<Tuple>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreimpl<Tuple> Copy for PropertyInputTypes<Tuple>
impl<Tuple> Send for PropertyInputTypes<Tuple>
impl<Tuple> Sync for PropertyInputTypes<Tuple>
Auto Trait Implementations§
impl<Tuple> Freeze for PropertyInputTypes<Tuple>
impl<Tuple> RefUnwindSafe for PropertyInputTypes<Tuple>where
Tuple: RefUnwindSafe,
impl<Tuple> Unpin for PropertyInputTypes<Tuple>where
Tuple: Unpin,
impl<Tuple> UnwindSafe for PropertyInputTypes<Tuple>where
Tuple: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more