use iced::{Element, Length}; use iced_aw::style::number_input::Style; use iced_aw::NumberInput; use num_traits::{bounds::Bounded, Num, NumAssignOps}; use std::fmt::Display; use std::marker::PhantomData; use std::str::FromStr; #[derive(Debug, Default)] pub struct NumInput { pub value: V, phantomdata: PhantomData, } #[derive(Debug, Clone, PartialEq, Eq)] pub enum NumInputMessage { Change(V), } impl NumInputMessage where V: Num + NumAssignOps + PartialOrd + Display + FromStr + Copy + Bounded, { pub fn get_data(&self) -> V { let NumInputMessage::Change(data) = self; *data } } impl NumInputMessage where V: Eq + Copy, { pub fn get_enum(&self) -> V { let NumInputMessage::Change(data) = self; *data } } impl<'a, V, M> NumInput where V: Num + NumAssignOps + PartialOrd + Display + FromStr + Copy + Bounded, M: 'a + Clone, { pub fn new(value: V) -> NumInput where V: 'static, { NumInput { value, phantomdata: PhantomData, } } pub fn view( &self, id: usize, min: V, max: V, step: V, on_change: F, style: Option