Function rui::with_ref

source ·
pub fn with_ref<V: View, F: Fn(&T) -> V + 'static, T>(
    binding: impl Binding<T>,
    f: F
) -> impl View
Expand description

Convenience to retreive a reference to a value in the context.

Examples found in repository?
examples/slider.rs (lines 10-15)
9
10
11
12
13
14
15
16
fn my_slider(s: impl Binding<f32>) -> impl View {
    with_ref(s, move |v| {
        vstack((
            v.to_string().font_size(10).padding(Auto),
            hslider(s).thumb_color(RED_HIGHLIGHT).padding(Auto),
        ))
    })
}