use crate::{impl_scalar_internal, Result, Scalar, Value}; macro_rules! impl_float_scalars { ($($ty:ty),*) => { $( impl Scalar for $ty { fn type_name() -> &'static str { "Float" } fn description() -> Option<&'static str> { Some("The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).") } fn parse(value: &Value) -> Option { match value { Value::Int(n) => Some(n.as_i64().unwrap() as Self), Value::Float(n) => Some(*n as Self), _ => None } } fn to_json(&self) -> Result { Ok((*self).into()) } } impl_scalar_internal!($ty); )* }; } impl_float_scalars!(f32, f64);