Struct gtk4::ConstantExpression
source · [−]#[repr(transparent)]pub struct ConstantExpression { /* private fields */ }
Implementations
Methods from Deref<Target = Expression>
Similar to Self::evaluate
but panics if the value is of a different type.
Create a PropertyExpression
that looks up for
property_name
with self as parameter. This is useful in long chains of
Expression
s.
Create a ClosureExpression
from a glib::Closure
with self
as the second parameter and R
as the return type. The return type is checked at run-time
and must always be specified. This is useful in long chains of
Expression
s when using the [glib::closure!
] macro.
Note that the first parameter will always be the this
object bound to the expression. If
None
is passed as this
then the type of the first parameter must be
Option<glib::Object>
otherwise type checking will panic.
use gtk::prelude::*;
use gtk::glib;
use glib::{closure, Object};
let button = gtk::Button::new();
button.set_label("Hello");
let label = button
.property_expression("label")
.chain_closure::<String>(closure!(|_: Option<Object>, label: &str| {
format!("{} World", label)
}))
.evaluate_as::<String, _>(gtk::Widget::NONE);
assert_eq!(label.unwrap(), "Hello World");
pub fn chain_closure_with_callback<F, R>(&self, f: F) -> ClosureExpression where
F: Fn(&[Value]) -> R + 'static,
R: ValueType,
pub fn chain_closure_with_callback<F, R>(&self, f: F) -> ClosureExpression where
F: Fn(&[Value]) -> R + 'static,
R: ValueType,
Create a ClosureExpression
with self as the second parameter.
This is useful in long chains of Expression
s.
Trait Implementations
Performs the conversion.
type Target = Expression
type Target = Expression
The resulting type after dereferencing.
type Checker = GenericValueTypeOrNoneChecker<Self>
type Checker = GenericValueTypeOrNoneChecker<Self>
Value type checker.
Get the contained value from a Value
. Read more
Returns the type identifier of Self
.
Convert an Option
to a Value
.
Auto Trait Implementations
impl RefUnwindSafe for ConstantExpression
impl !Send for ConstantExpression
impl !Sync for ConstantExpression
impl Unpin for ConstantExpression
impl UnwindSafe for ConstantExpression
Blanket Implementations
Mutably borrows from an owned value. Read more