add floating point de/ser-ialization
This commit is contained in:
@@ -60,6 +60,14 @@ pub trait Visitor<'de>: Sized {
|
||||
Err(format!("Unexpected u64 {:?}", v))
|
||||
}
|
||||
|
||||
fn visit_f32(self, v: &str) -> Result<Self::Value, String> {
|
||||
Err(format!("Unexpected f32 {:?}", v))
|
||||
}
|
||||
|
||||
fn visit_f64(self, v: &str) -> Result<Self::Value, String> {
|
||||
Err(format!("Unexpected f64 {:?}", v))
|
||||
}
|
||||
|
||||
fn visit_str(self, v: &str) -> Result<Self::Value, String> {
|
||||
Err(format!("Unexpected str {:?}", v))
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ fn de_type() {
|
||||
convert_and_validate!(u64, 12 as u64, "12");
|
||||
convert_and_validate!(i64, 12 as i64, "12");
|
||||
convert_and_validate!(i64, -12 as i64, "-12");
|
||||
convert_and_validate!(f32, -12.5_f32 as f32, "-12.5");
|
||||
convert_and_validate!(f64, -12.5 as f64, "-12.5");
|
||||
|
||||
convert_and_validate_for_attribute!(bool, true, "true");
|
||||
convert_and_validate_for_attribute!(u8, 12 as u8, "12");
|
||||
@@ -75,4 +77,6 @@ fn de_type() {
|
||||
convert_and_validate_for_attribute!(u64, 12 as u64, "12");
|
||||
convert_and_validate_for_attribute!(i64, 12 as i64, "12");
|
||||
convert_and_validate_for_attribute!(i64, -12 as i64, "-12");
|
||||
convert_and_validate_for_attribute!(f32, -12.5 as f32, "-12.5");
|
||||
convert_and_validate_for_attribute!(f64, -12.5 as f64, "-12.5");
|
||||
}
|
||||
|
||||
@@ -57,6 +57,8 @@ fn ser_type() {
|
||||
convert_and_validate!(u64, 12 as u64, "12");
|
||||
convert_and_validate!(i64, 12 as i64, "12");
|
||||
convert_and_validate!(i64, -12 as i64, "-12");
|
||||
convert_and_validate!(f32, -12.5 as f32, "-12.5");
|
||||
convert_and_validate!(f64, -12.5 as f64, "-12.5");
|
||||
|
||||
convert_and_validate_as_attribute!(bool, true, "true");
|
||||
convert_and_validate_as_attribute!(u8, 12 as u8, "12");
|
||||
@@ -71,4 +73,6 @@ fn ser_type() {
|
||||
convert_and_validate_as_attribute!(u64, 12 as u64, "12");
|
||||
convert_and_validate_as_attribute!(i64, 12 as i64, "12");
|
||||
convert_and_validate_as_attribute!(i64, -12 as i64, "-12");
|
||||
convert_and_validate_as_attribute!(f32, -12.5 as f32, "-12.5");
|
||||
convert_and_validate_as_attribute!(f64, -12.5 as f64, "-12.5");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user