rain_lang/value/primitive/
mod.rs

1/*!
2Primitive `rain` types and values
3*/
4
5pub mod logical;
6pub mod binary;
7
8use std::fmt::{self, Debug, Display, Formatter};
9
10macro_rules! debug_from_display {
11    ($d_ty:ty) => {
12        impl Debug for $d_ty {
13            fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
14                <Self as Display>::fmt(self, fmt)
15            }
16        }
17    }
18}
19
20macro_rules! unit_primitive {
21    ($u_ty:ty, $name:literal) => {
22        impl Display for $u_ty {
23            fn fmt(&self, fmt: &mut Formatter) -> Result<(), fmt::Error> {
24                write!(fmt, $name)
25            }
26        }
27        debug_from_display!($u_ty);
28    }
29}
30
31/// The unit type
32#[derive(Copy, Clone, Eq, PartialEq, Hash)]
33pub struct Unit;
34unit_primitive!(Unit, "#unit");
35
36/// The empty type
37#[derive(Copy, Clone, Eq, PartialEq, Hash)]
38pub struct Empty;
39unit_primitive!(Empty, "#empty");