Change token to use FloatWrapper.
This commit is contained in:
12
src/ast.rs
12
src/ast.rs
@@ -10,6 +10,7 @@ use crate::stdlib::{
|
||||
hash::Hash,
|
||||
num::{NonZeroU64, NonZeroUsize},
|
||||
ops::{Add, AddAssign},
|
||||
str::FromStr,
|
||||
string::String,
|
||||
vec,
|
||||
vec::Vec,
|
||||
@@ -1126,7 +1127,7 @@ pub struct FnCallExpr {
|
||||
|
||||
/// A type that wraps a [`FLOAT`] and implements [`Hash`].
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, PartialEq, PartialOrd)]
|
||||
pub struct FloatWrapper(FLOAT);
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
@@ -1195,6 +1196,15 @@ impl From<FLOAT> for FloatWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
impl FromStr for FloatWrapper {
|
||||
type Err = <FLOAT as FromStr>::Err;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
FLOAT::from_str(s).map(Into::<Self>::into)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
impl FloatWrapper {
|
||||
pub const fn new(value: FLOAT) -> Self {
|
||||
|
Reference in New Issue
Block a user