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 IntoUiNode, bar: impl IntoVar<bool>) -> UiNode {
}
assert_eq!(
property_input_types!(foo).type_id(),
PropertyInputTypes::<(Var<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 IntoUiNode, bar: impl IntoVar<bool>) -> UiNode {
}
trait SingleBoolVar {
fn is_single_bool_var(self) -> bool;
}
// match
impl<'a> SingleBoolVar for &'a PropertyInputTypes<(Var<bool>,)> {
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 duplicate 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,
§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