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>
Trait Implementations§
source§impl<Tuple> Clone for PropertyInputTypes<Tuple>
impl<Tuple> Clone for PropertyInputTypes<Tuple>
impl<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> 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> 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