AllowedNumericType.is_ok() takes ParingMode as well.

And it returns true if ParsingMode.allows_all_numeric_values is true regardless
of AllowedNumericType itself.
This commit is contained in:
Hiroyuki Ikezoe 2017-06-14 09:52:05 +09:00
parent 7341574b66
commit 6c5915068a
3 changed files with 27 additions and 22 deletions

View file

@ -265,7 +265,10 @@ pub mod specified {
impl AllowedNumericType {
/// Whether the value fits the rules of this numeric type.
#[inline]
pub fn is_ok(&self, val: f32) -> bool {
pub fn is_ok(&self, parsing_mode: ParsingMode, val: f32) -> bool {
if parsing_mode.allows_all_numeric_values() {
return true;
}
match *self {
AllowedNumericType::All => true,
AllowedNumericType::NonNegative => val >= 0.0,