mirror of
https://github.com/Dummi26/mers.git
synced 2025-03-12 00:07:46 +01:00
48 lines
1.0 KiB
Rust
48 lines
1.0 KiB
Rust
![]() |
use std::{any::Any, fmt::Display};
|
||
|
|
||
|
use super::{MersData, MersType, Type};
|
||
|
|
||
|
#[derive(Debug, Clone)]
|
||
|
pub struct Float(pub f64);
|
||
|
|
||
|
impl MersData for Float {
|
||
|
fn clone(&self) -> Box<dyn MersData> {
|
||
|
Box::new(Clone::clone(self))
|
||
|
}
|
||
|
fn as_any(&self) -> &dyn Any {
|
||
|
self
|
||
|
}
|
||
|
fn mut_any(&mut self) -> &mut dyn Any {
|
||
|
self
|
||
|
}
|
||
|
fn to_any(self) -> Box<dyn Any> {
|
||
|
Box::new(self)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[derive(Debug)]
|
||
|
pub struct FloatT;
|
||
|
impl MersType for FloatT {
|
||
|
fn is_same_type_as(&self, other: &dyn MersType) -> bool {
|
||
|
other.as_any().downcast_ref::<Self>().is_some()
|
||
|
}
|
||
|
fn is_included_in_single(&self, target: &dyn MersType) -> bool {
|
||
|
self.is_same_type_as(target)
|
||
|
}
|
||
|
fn as_any(&self) -> &dyn Any {
|
||
|
self
|
||
|
}
|
||
|
fn mut_any(&mut self) -> &mut dyn Any {
|
||
|
self
|
||
|
}
|
||
|
fn to_any(self) -> Box<dyn Any> {
|
||
|
Box::new(self)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
impl Display for Float {
|
||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||
|
write!(f, "{}", self.0)
|
||
|
}
|
||
|
}
|