RosettaCodeData/Task/Determine-if-a-string-is-numeric/Rust/determine-if-a-string-is-numeric.rust

5 lines
181 B
Text
Raw Permalink Normal View History

2017-09-23 10:01:46 +02:00
// This function is not limited to just numeric types but rather anything that implements the FromStr trait.
fn parsable<T: FromStr>(s: &str) -> bool {
s.parse::<T>().is_ok()
}