[types] Move exactness flag to is_exact() method on Number
This commit is contained in:
parent
f18b6a5719
commit
9801113c01
1 changed files with 3 additions and 13 deletions
|
@ -8,7 +8,6 @@
|
|||
|
||||
mod integer;
|
||||
|
||||
use std::fmt;
|
||||
use object::Object;
|
||||
|
||||
pub use self::integer::Int;
|
||||
|
@ -16,19 +15,10 @@ pub use self::integer::Int;
|
|||
pub trait Number:
|
||||
Object
|
||||
{
|
||||
/// Cast this Number to an Int if possible.
|
||||
fn as_int(&self) -> Option<&Int> { None }
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub enum Exact { Yes, No }
|
||||
|
||||
impl fmt::Display for Exact {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", match *self {
|
||||
Exact::Yes => "#e",
|
||||
Exact::No => "#i",
|
||||
})
|
||||
}
|
||||
/// Return `true` if this Number is an exact representation of its value.
|
||||
fn is_exact(&self) -> bool { true }
|
||||
}
|
||||
|
||||
// TODO: Implement PartialEq myself cause there are some weird nuances to comparing numbers.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue