Trait string_patterns::IsNumeric
source · pub trait IsNumeric {
// Required method
fn is_numeric(&self) -> bool;
}
Expand description
Method to check if the string may be parsed to an integer or float
Required Methods§
sourcefn is_numeric(&self) -> bool
fn is_numeric(&self) -> bool
strict check on a numeric string before using .parse::<T>()
use trim() or correct_numeric_string() first for looser number validation
This mirrors a similar function in PHP, but is will fail with spaces or
any non-numeric characters other than a leading minus or a single decimal point
For characters, is_numeric checks for decimal digit-equivalent characters
Implementations on Foreign Types§
source§impl IsNumeric for str
impl IsNumeric for str
Implementation for &str / String
source§fn is_numeric(&self) -> bool
fn is_numeric(&self) -> bool
Check if the string may be parsed to a number This is a now a strict regex-free check Use trim() or correct_numeric_string() first for looser number validation