pub trait IntoVar<T>where
T: VarValue,{
type Var: Var<T>;
// Required method
fn into_var(self) -> Self::Var;
// Provided method
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized { ... }
}
Expand description
A value-to-var conversion that consumes the value.
Every Var<T>
implements this to convert to itself, every VarValue
implements this to
convert to a LocalVar<T>
.
This trait is used by most properties, it allows then to accept literal values, variables and context variables
all with a single signature. Together with Var<T>
this gives properties great flexibility of usage, at zero-cost. Widget
when
blocks also use IntoVar<T>
to support changing the property value depending on the widget state.
Value types can also manually implement this to support a shorthand literal syntax for when they are used in properties,
this converts the shorthand value like a tuple into the actual value type and wraps it into a variable, usually LocalVar
too. They can implement the trait multiple times to support different shorthand syntaxes or different types in the shorthand
value.
Required Associated Types§
Required Methods§
Provided Methods§
sourcefn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
Converts into BoxedVar<T>
.
This method exists to help the type system infer the type in this scenario:
fn foo(foo: impl IntoVar<bool>) { }
foo(if bar {
BAR_VAR.map(|b| !*b).boxed()
} else {
true.into_boxed_var()
});
We need a BoxedVar<bool>
to unify the input types that can be a map
var or a LocalVar<bool>
. Writing true.into_var().boxed()
causes the type inference to fail, requiring us to write IntoVar::<bool>::into_var(true).boxed()
.
Implementations on Foreign Types§
source§impl IntoVar<GradientStop> for f32
impl IntoVar<GradientStop> for f32
source§fn into_var(self) -> <f32 as IntoVar<GradientStop>>::Var
fn into_var(self) -> <f32 as IntoVar<GradientStop>>::Var
Conversion to Length::Dip
color hint.
type Var = LocalVar<GradientStop>
source§impl IntoVar<GradientStop> for i32
impl IntoVar<GradientStop> for i32
source§fn into_var(self) -> <i32 as IntoVar<GradientStop>>::Var
fn into_var(self) -> <i32 as IntoVar<GradientStop>>::Var
Conversion to Length::Dip
color hint.
type Var = LocalVar<GradientStop>
source§impl IntoVar<DragDropData> for &'static str
impl IntoVar<DragDropData> for &'static str
source§impl IntoVar<DragDropData> for String
impl IntoVar<DragDropData> for String
source§impl IntoVar<DragDropData> for PathBuf
impl IntoVar<DragDropData> for PathBuf
source§impl IntoVar<CommandScope> for &'static str
impl IntoVar<CommandScope> for &'static str
source§impl IntoVar<FontColorPalette> for u16
impl IntoVar<FontColorPalette> for u16
source§impl IntoVar<FontStyleSet> for u8
impl IntoVar<FontStyleSet> for u8
source§impl IntoVar<GlyphSource> for &'static str
impl IntoVar<GlyphSource> for &'static str
source§impl IntoVar<GlyphSource> for char
impl IntoVar<GlyphSource> for char
source§impl IntoVar<ImageRepeat> for bool
impl IntoVar<ImageRepeat> for bool
source§impl IntoVar<ImageSource> for &'static [u8]
impl IntoVar<ImageSource> for &'static [u8]
source§impl IntoVar<ImageSource> for &str
impl IntoVar<ImageSource> for &str
source§impl IntoVar<ImageSource> for &Path
impl IntoVar<ImageSource> for &Path
source§impl IntoVar<ImageSource> for String
impl IntoVar<ImageSource> for String
source§impl IntoVar<ImageSource> for PathBuf
impl IntoVar<ImageSource> for PathBuf
source§impl IntoVar<L10nArgument> for &'static str
impl IntoVar<L10nArgument> for &'static str
source§impl IntoVar<L10nArgument> for bool
impl IntoVar<L10nArgument> for bool
source§impl IntoVar<L10nArgument> for char
impl IntoVar<L10nArgument> for char
source§impl IntoVar<L10nArgument> for f32
impl IntoVar<L10nArgument> for f32
source§impl IntoVar<L10nArgument> for f64
impl IntoVar<L10nArgument> for f64
source§impl IntoVar<L10nArgument> for i8
impl IntoVar<L10nArgument> for i8
source§impl IntoVar<L10nArgument> for i16
impl IntoVar<L10nArgument> for i16
source§impl IntoVar<L10nArgument> for i32
impl IntoVar<L10nArgument> for i32
source§impl IntoVar<L10nArgument> for i64
impl IntoVar<L10nArgument> for i64
source§impl IntoVar<L10nArgument> for i128
impl IntoVar<L10nArgument> for i128
source§impl IntoVar<L10nArgument> for isize
impl IntoVar<L10nArgument> for isize
source§impl IntoVar<L10nArgument> for u8
impl IntoVar<L10nArgument> for u8
source§impl IntoVar<L10nArgument> for u16
impl IntoVar<L10nArgument> for u16
source§impl IntoVar<L10nArgument> for u32
impl IntoVar<L10nArgument> for u32
source§impl IntoVar<L10nArgument> for u64
impl IntoVar<L10nArgument> for u64
source§impl IntoVar<L10nArgument> for u128
impl IntoVar<L10nArgument> for u128
source§impl IntoVar<L10nArgument> for usize
impl IntoVar<L10nArgument> for usize
source§impl IntoVar<L10nArgument> for String
impl IntoVar<L10nArgument> for String
source§impl IntoVar<L10nArgument> for FluentNumber
impl IntoVar<L10nArgument> for FluentNumber
source§impl IntoVar<InlineMode> for bool
impl IntoVar<InlineMode> for bool
source§impl IntoVar<CursorSource> for bool
impl IntoVar<CursorSource> for bool
source§impl IntoVar<CaptureMode> for bool
impl IntoVar<CaptureMode> for bool
source§fn into_var(self) -> <bool as IntoVar<CaptureMode>>::Var
fn into_var(self) -> <bool as IntoVar<CaptureMode>>::Var
Convert true
to CaptureMode::Widget
and false
to CaptureMode::Window
.
type Var = LocalVar<CaptureMode>
source§impl IntoVar<ContextCapture> for bool
impl IntoVar<ContextCapture> for bool
source§impl IntoVar<ScrollToTarget> for &'static str
impl IntoVar<ScrollToTarget> for &'static str
source§impl IntoVar<InteractiveCaretMode> for bool
impl IntoVar<InteractiveCaretMode> for bool
source§impl IntoVar<TextOverflow> for &'static str
impl IntoVar<TextOverflow> for &'static str
source§impl IntoVar<TextOverflow> for bool
impl IntoVar<TextOverflow> for bool
source§impl IntoVar<TextOverflow> for char
impl IntoVar<TextOverflow> for char
source§impl IntoVar<TextOverflow> for String
impl IntoVar<TextOverflow> for String
source§impl IntoVar<HitTestMode> for bool
impl IntoVar<HitTestMode> for bool
source§impl IntoVar<RepeatMode> for bool
impl IntoVar<RepeatMode> for bool
source§impl IntoVar<Visibility> for bool
impl IntoVar<Visibility> for bool
source§impl IntoVar<TreeFilter> for bool
impl IntoVar<TreeFilter> for bool
source§impl IntoVar<BlockWindowLoad> for bool
impl IntoVar<BlockWindowLoad> for bool
source§impl IntoVar<BlockWindowLoad> for Duration
impl IntoVar<BlockWindowLoad> for Duration
source§impl IntoVar<WindowIcon> for &'static [u8]
impl IntoVar<WindowIcon> for &'static [u8]
source§impl IntoVar<WindowIcon> for &str
impl IntoVar<WindowIcon> for &str
source§fn into_var(self) -> <&str as IntoVar<WindowIcon>>::Var
fn into_var(self) -> <&str as IntoVar<WindowIcon>>::Var
See ImageSource
conversion from &str
type Var = LocalVar<WindowIcon>
source§impl IntoVar<WindowIcon> for &Path
impl IntoVar<WindowIcon> for &Path
source§impl IntoVar<WindowIcon> for String
impl IntoVar<WindowIcon> for String
source§impl IntoVar<WindowIcon> for PathBuf
impl IntoVar<WindowIcon> for PathBuf
source§impl IntoVar<InspectMode> for bool
impl IntoVar<InspectMode> for bool
source§impl IntoVar<Option<AccessState>> for AccessState
impl IntoVar<Option<AccessState>> for AccessState
type Var = LocalVar<Option<AccessState>>
fn into_var(self) -> <AccessState as IntoVar<Option<AccessState>>>::Var
source§impl IntoVar<Option<AccessNodeId>> for AccessNodeId
impl IntoVar<Option<AccessNodeId>> for AccessNodeId
type Var = LocalVar<Option<AccessNodeId>>
fn into_var(self) -> <AccessNodeId as IntoVar<Option<AccessNodeId>>>::Var
source§impl IntoVar<GradientRadius> for f32
impl IntoVar<GradientRadius> for f32
source§fn into_var(self) -> <f32 as IntoVar<GradientRadius>>::Var
fn into_var(self) -> <f32 as IntoVar<GradientRadius>>::Var
Conversion to Length::DipF32
and to radius.
type Var = LocalVar<GradientRadius>
source§impl IntoVar<GradientRadius> for i32
impl IntoVar<GradientRadius> for i32
source§fn into_var(self) -> <i32 as IntoVar<GradientRadius>>::Var
fn into_var(self) -> <i32 as IntoVar<GradientRadius>>::Var
Conversion to Length::Dip
and to radius.
type Var = LocalVar<GradientRadius>
source§impl IntoVar<GradientStops> for &[Hsla]
impl IntoVar<GradientStops> for &[Hsla]
source§impl IntoVar<GradientStops> for &[Hsva]
impl IntoVar<GradientStops> for &[Hsva]
source§impl IntoVar<GradientStops> for &[Rgba]
impl IntoVar<GradientStops> for &[Rgba]
source§impl IntoVar<CategoryId> for &'static str
impl IntoVar<CategoryId> for &'static str
source§impl IntoVar<CategoryId> for String
impl IntoVar<CategoryId> for String
source§impl IntoVar<DialogKind> for bool
impl IntoVar<DialogKind> for bool
source§impl IntoVar<FileDialogFilters> for &'static str
impl IntoVar<FileDialogFilters> for &'static str
source§impl IntoVar<Response> for MsgDialogResponse
impl IntoVar<Response> for MsgDialogResponse
source§impl IntoVar<CharVariant> for u8
impl IntoVar<CharVariant> for u8
source§impl IntoVar<FontFeatureState> for bool
impl IntoVar<FontFeatureState> for bool
source§impl IntoVar<FontFeatureState> for u32
impl IntoVar<FontFeatureState> for u32
source§impl IntoVar<FontStretch> for f32
impl IntoVar<FontStretch> for f32
source§impl IntoVar<FontWeight> for f32
impl IntoVar<FontWeight> for f32
source§impl IntoVar<FontWeight> for u32
impl IntoVar<FontWeight> for u32
source§impl IntoVar<LangFilePath> for &'static str
impl IntoVar<LangFilePath> for &'static str
source§impl IntoVar<LangFilePath> for String
impl IntoVar<LangFilePath> for String
source§impl IntoVar<LayerIndex> for u32
impl IntoVar<LayerIndex> for u32
source§impl IntoVar<ByteLength> for usize
impl IntoVar<ByteLength> for usize
source§impl IntoVar<GridSpacing> for f32
impl IntoVar<GridSpacing> for f32
source§impl IntoVar<GridSpacing> for i32
impl IntoVar<GridSpacing> for i32
source§impl IntoVar<SideOffsets> for f32
impl IntoVar<SideOffsets> for f32
source§impl IntoVar<SideOffsets> for i32
impl IntoVar<SideOffsets> for i32
source§impl IntoVar<FontSynthesis> for bool
impl IntoVar<FontSynthesis> for bool
source§impl IntoVar<ScrollRequest> for bool
impl IntoVar<ScrollRequest> for bool
source§impl IntoVar<ScrollMode> for bool
impl IntoVar<ScrollMode> for bool
source§impl IntoVar<SmoothScrolling> for bool
impl IntoVar<SmoothScrolling> for bool
source§impl IntoVar<SmoothScrolling> for Duration
impl IntoVar<SmoothScrolling> for Duration
source§impl IntoVar<AutoSelection> for bool
impl IntoVar<AutoSelection> for bool
source§impl IntoVar<TouchTransformMode> for bool
impl IntoVar<TouchTransformMode> for bool
source§impl IntoVar<Importance> for u32
impl IntoVar<Importance> for u32
source§impl IntoVar<Interactivity> for bool
impl IntoVar<Interactivity> for bool
source§impl IntoVar<BorderRepeats> for bool
impl IntoVar<BorderRepeats> for bool
source§impl IntoVar<CornerRadius> for f32
impl IntoVar<CornerRadius> for f32
source§impl IntoVar<CornerRadius> for i32
impl IntoVar<CornerRadius> for i32
source§impl IntoVar<ParallelWin> for bool
impl IntoVar<ParallelWin> for bool
source§impl<B, R> IntoVar<GradientRadius> for (B, R)
impl<B, R> IntoVar<GradientRadius> for (B, R)
source§fn into_var(self) -> <(B, R) as IntoVar<GradientRadius>>::Var
fn into_var(self) -> <(B, R) as IntoVar<GradientRadius>>::Var
Ellipse GradientRadiusBase
and ellipse radius.
type Var = LocalVar<GradientRadius>
source§impl<C, O> IntoVar<GradientStop> for (C, O)
impl<C, O> IntoVar<GradientStop> for (C, O)
source§impl<C, R> IntoVar<GridSpacing> for (C, R)
impl<C, R> IntoVar<GridSpacing> for (C, R)
source§impl<C, S> IntoVar<BorderSide> for (C, S)
impl<C, S> IntoVar<BorderSide> for (C, S)
source§impl<C, S> IntoVar<BorderSides> for (C, S)
impl<C, S> IntoVar<BorderSides> for (C, S)
source§impl<F> IntoVar<ImageSource> for (&'static [u8], F)where
F: Into<ImageDataFormat>,
impl<F> IntoVar<ImageSource> for (&'static [u8], F)where
F: Into<ImageDataFormat>,
source§impl<F> IntoVar<ImageSource> for (Arc<Vec<u8>>, F)where
F: Into<ImageDataFormat>,
impl<F> IntoVar<ImageSource> for (Arc<Vec<u8>>, F)where
F: Into<ImageDataFormat>,
source§impl<F> IntoVar<ImageSource> for (Vec<u8>, F)where
F: Into<ImageDataFormat>,
impl<F> IntoVar<ImageSource> for (Vec<u8>, F)where
F: Into<ImageDataFormat>,
source§impl<F> IntoVar<WindowIcon> for (&'static [u8], F)where
F: Into<ImageDataFormat>,
impl<F> IntoVar<WindowIcon> for (&'static [u8], F)where
F: Into<ImageDataFormat>,
source§impl<F> IntoVar<WindowIcon> for (Arc<Vec<u8>>, F)where
F: Into<ImageDataFormat>,
impl<F> IntoVar<WindowIcon> for (Arc<Vec<u8>>, F)where
F: Into<ImageDataFormat>,
source§impl<F> IntoVar<WindowIcon> for (Vec<u8>, F)where
F: Into<ImageDataFormat>,
impl<F> IntoVar<WindowIcon> for (Vec<u8>, F)where
F: Into<ImageDataFormat>,
source§impl<F> IntoVar<SmoothScrolling> for (Duration, F)
impl<F> IntoVar<SmoothScrolling> for (Duration, F)
source§impl<F, const N: usize> IntoVar<ImageSource> for (&'static [u8; N], F)where
F: Into<ImageDataFormat>,
impl<F, const N: usize> IntoVar<ImageSource> for (&'static [u8; N], F)where
F: Into<ImageDataFormat>,
source§impl<F, const N: usize> IntoVar<WindowIcon> for (&'static [u8; N], F)where
F: Into<ImageDataFormat>,
impl<F, const N: usize> IntoVar<WindowIcon> for (&'static [u8; N], F)where
F: Into<ImageDataFormat>,
source§impl<L> IntoVar<GradientStops> for &[(Hsla, L)]
impl<L> IntoVar<GradientStops> for &[(Hsla, L)]
source§impl<L> IntoVar<GradientStops> for &[(Hsva, L)]
impl<L> IntoVar<GradientStops> for &[(Hsva, L)]
source§impl<L> IntoVar<GradientStops> for &[(Rgba, L)]
impl<L> IntoVar<GradientStops> for &[(Rgba, L)]
source§impl<L, const N: usize> IntoVar<GradientStops> for &[(Hsla, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for &[(Hsla, L); N]
source§impl<L, const N: usize> IntoVar<GradientStops> for &[(Hsva, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for &[(Hsva, L); N]
source§impl<L, const N: usize> IntoVar<GradientStops> for &[(Rgba, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for &[(Rgba, L); N]
source§impl<L, const N: usize> IntoVar<GradientStops> for [(Hsla, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for [(Hsla, L); N]
source§impl<L, const N: usize> IntoVar<GradientStops> for [(Hsva, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for [(Hsva, L); N]
source§impl<L, const N: usize> IntoVar<GradientStops> for [(Rgba, L); N]
impl<L, const N: usize> IntoVar<GradientStops> for [(Rgba, L); N]
source§impl<P, O> IntoVar<AnchorTransform> for (P, O)
impl<P, O> IntoVar<AnchorTransform> for (P, O)
source§impl<P, O> IntoVar<AnchorOffset> for (P, O)
impl<P, O> IntoVar<AnchorOffset> for (P, O)
source§impl<P, O> IntoVar<StackDirection> for (P, O, bool)
impl<P, O> IntoVar<StackDirection> for (P, O, bool)
source§impl<P, O> IntoVar<StackDirection> for (P, O)
impl<P, O> IntoVar<StackDirection> for (P, O)
source§impl<T, R, B, L> IntoVar<FactorSideOffsets> for (T, R, B, L)
impl<T, R, B, L> IntoVar<FactorSideOffsets> for (T, R, B, L)
source§fn into_var(self) -> <(T, R, B, L) as IntoVar<FactorSideOffsets>>::Var
fn into_var(self) -> <(T, R, B, L) as IntoVar<FactorSideOffsets>>::Var
New top, right, bottom, left.
type Var = LocalVar<FactorSideOffsets>
source§impl<T, R, B, L> IntoVar<SideOffsets> for (T, R, B, L)
impl<T, R, B, L> IntoVar<SideOffsets> for (T, R, B, L)
source§fn into_var(self) -> <(T, R, B, L) as IntoVar<SideOffsets>>::Var
fn into_var(self) -> <(T, R, B, L) as IntoVar<SideOffsets>>::Var
(top, right, bottom, left)
type Var = LocalVar<SideOffsets>
source§impl<T, R, B, L> IntoVar<BorderSides> for (T, R, B, L)
impl<T, R, B, L> IntoVar<BorderSides> for (T, R, B, L)
source§fn into_var(self) -> <(T, R, B, L) as IntoVar<BorderSides>>::Var
fn into_var(self) -> <(T, R, B, L) as IntoVar<BorderSides>>::Var
(top, right, bottom, left) sides.
type Var = LocalVar<BorderSides>
source§impl<T, R, B, L, S> IntoVar<BorderSides> for (T, R, B, L, S)
impl<T, R, B, L, S> IntoVar<BorderSides> for (T, R, B, L, S)
source§fn into_var(self) -> <(T, R, B, L, S) as IntoVar<BorderSides>>::Var
fn into_var(self) -> <(T, R, B, L, S) as IntoVar<BorderSides>>::Var
(top-color, right-color, bottom-color, left-color, style) sides.
type Var = LocalVar<BorderSides>
source§impl<T, S> IntoVar<AnchorMode> for (T, S)
impl<T, S> IntoVar<AnchorMode> for (T, S)
source§impl<TB, LR> IntoVar<FactorSideOffsets> for (TB, LR)
impl<TB, LR> IntoVar<FactorSideOffsets> for (TB, LR)
source§impl<TB, LR> IntoVar<SideOffsets> for (TB, LR)
impl<TB, LR> IntoVar<SideOffsets> for (TB, LR)
source§impl<TB, LR> IntoVar<BorderRepeats> for (TB, LR)
impl<TB, LR> IntoVar<BorderRepeats> for (TB, LR)
source§impl<TB, LR, S> IntoVar<BorderSides> for (TB, LR, S)
impl<TB, LR, S> IntoVar<BorderSides> for (TB, LR, S)
source§fn into_var(self) -> <(TB, LR, S) as IntoVar<BorderSides>>::Var
fn into_var(self) -> <(TB, LR, S) as IntoVar<BorderSides>>::Var
(top-bottom-color, left-right-color, style) sides.
type Var = LocalVar<BorderSides>
source§impl<TL, TR, BR, BL> IntoVar<CornerRadius> for (TL, TR, BR, BL)
impl<TL, TR, BR, BL> IntoVar<CornerRadius> for (TL, TR, BR, BL)
source§fn into_var(self) -> <(TL, TR, BR, BL) as IntoVar<CornerRadius>>::Var
fn into_var(self) -> <(TL, TR, BR, BL) as IntoVar<CornerRadius>>::Var
(top-left, top-right, bottom-left, bottom-right) corners.