1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pub use self::{configure::*, fs::*, misc::*, time::*};
pub(crate) mod configure;
pub(crate) mod fs;
pub(crate) mod time;
pub(crate) mod misc {
use std::{str::FromStr, string::ToString};
pub fn is_float<T: ToString>(data: &T) -> bool {
match f64::from_str(&data.to_string()) {
Err(_) => false,
Ok(_) => true,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_is_float() {
let data = vec!["1", "-10", "ifjuka87"];
assert!(is_float(&data[0]));
assert!(is_float(&data[1]));
assert!(is_float(&data[2]) == false)
}
}