feat: usable?
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::fmt::{Debug, Formatter, Result as FmtResult};
|
||||
use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
|
||||
|
||||
use derive_more::{Constructor, IsVariant, Unwrap};
|
||||
use rpds::{HashTrieMapSync, VectorSync};
|
||||
@@ -24,11 +24,30 @@ impl Debug for AttrSet {
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for AttrSet {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||
write!(f, "{{ ")?;
|
||||
for (k, v) in self.data.iter() {
|
||||
write!(f, "{k} = {v}; ")?;
|
||||
}
|
||||
write!(f, "}}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Constructor, Clone, Debug, PartialEq)]
|
||||
pub struct List {
|
||||
data: VectorSync<Value>,
|
||||
}
|
||||
|
||||
impl Display for List {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||
write!(f, "[ ")?;
|
||||
for v in self.data.iter() {
|
||||
write!(f, "{v} ")?;
|
||||
}
|
||||
write!(f, "]")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(IsVariant, Unwrap, Clone, Debug, PartialEq)]
|
||||
pub enum Value {
|
||||
@@ -41,3 +60,19 @@ pub enum Value {
|
||||
PrimOp(&'static str),
|
||||
PartialPrimOp(&'static str),
|
||||
}
|
||||
|
||||
impl Display for Value {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
|
||||
use Value::*;
|
||||
match self {
|
||||
Const(x) => write!(f, "{x}"),
|
||||
AttrSet(x) => write!(f, "{x}"),
|
||||
List(x) => write!(f, "{x}"),
|
||||
Catchable(x) => write!(f, "{x}"),
|
||||
Thunk => write!(f, "<CODE>"),
|
||||
Func => write!(f, "<LAMBDA>"),
|
||||
PrimOp(x) => write!(f, "<PRIMOP {x}>"),
|
||||
PartialPrimOp(x) => write!(f, "<PARTIAL PRIMOP {x}>"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user