Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

use_min

Reactive min().

Works with any container that implements IntoIterator (Vec, HashSet, …) with any elements that implement PartialOrd and Clone (floats, ints, strings, …).

If the container is empty or only contains non comparable values like NaN, it returns None. Otherwise it returns the Some(<smallest value>) in the container.

Usage

use leptos::prelude::*;
use leptos_use_math::use_min;

#[component]
fn Demo() -> impl IntoView {
let (values, set_values) = signal(vec![1.0, 2.0, 3.0, f32::NAN, 4.0, 5.0]);
let result = use_min::<Vec<f32>, _, _>(values); // Some(1.0)

assert_eq!(result.get(), Some(1.0));
view! { }
}

Installation

cargo add leptos-use-math

Source

Source • Docs