leptos-use/src/math/use_floor.rs

31 lines
726 B
Rust
Raw Normal View History

2023-06-10 19:15:41 +01:00
use crate::math::shared::use_simple_math;
2023-06-03 05:25:45 +01:00
use leptos::*;
use num::Float;
2023-06-09 23:10:33 +01:00
use paste::paste;
2023-06-03 05:25:45 +01:00
2023-06-09 23:10:33 +01:00
use_simple_math!(
/// Reactive `floor()`.
///
/// ## Demo
///
/// [Link to Demo](https://github.com/Synphonyte/leptos-use/tree/main/examples/use_floor)
///
/// ## Usage
///
/// ```
/// # use leptos::*;
/// # use leptos_use::math::use_floor;
/// #
/// # #[component]
/// # fn Demo(cx: Scope) -> impl IntoView {
/// let (value, set_value) = create_signal(cx, 45.95);
/// let result: Signal<f64> = use_floor(cx, value); // 45
/// #
/// # assert_eq!(result.get(), 45.0);
/// # view! { cx, }
/// # }
/// ```
#[doc(cfg(feature = "math"))]
floor
);