Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
|
|
@ -0,0 +1,34 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
fn parsable<T: FromStr>(s: &str) -> bool {
|
||||
s.parse::<T>().is_ok()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let test_cases = [
|
||||
"142857",
|
||||
"3.14",
|
||||
"not of this earth!"
|
||||
];
|
||||
|
||||
let types: &[(&str, fn(&str) -> bool)] = &[
|
||||
("i32", parsable::<i32> as fn(&str) -> bool),
|
||||
("i64", parsable::<i32> as fn(&str) -> bool),
|
||||
("i128", parsable::<i32> as fn(&str) -> bool),
|
||||
|
||||
("f64", parsable::<f64> as fn(&str) -> bool),
|
||||
];
|
||||
|
||||
println!("");
|
||||
for &case in &test_cases {
|
||||
for &(type_name, parse_fn) in types {
|
||||
println!(
|
||||
"'{}' {} be parsed as {}",
|
||||
case,
|
||||
if parse_fn(case) { "can" } else { "_cannot_" },
|
||||
type_name
|
||||
);
|
||||
}
|
||||
println!("");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue