1 2 3 4 5 6 7 8 9 10 11 12 13
use std::str::FromStr; #[derive(Debug, Default, Clone)] pub struct DataInput { pub name: String, pub value: String, } impl DataInput { pub fn get<T: FromStr>(&self) -> Result<T, T::Err> { self.value.parse::<T>() } }