1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::{Any, CheckDerConstraints, Error, Real, Result, Tag, Tagged};
use core::convert::{TryFrom, TryInto};
impl<'a> TryFrom<Any<'a>> for f64 {
type Error = Error;
fn try_from(any: Any<'a>) -> Result<f64> {
any.tag().assert_eq(Self::TAG)?;
any.header.assert_primitive()?;
let real: Real = any.try_into()?;
Ok(real.f64())
}
}
impl<'a> CheckDerConstraints for f64 {
fn check_constraints(any: &Any) -> Result<()> {
any.header.assert_primitive()?;
any.header.length.assert_definite()?;
Ok(())
}
}
impl Tagged for f64 {
const TAG: Tag = Tag::RealType;
}