feat: usable?

This commit is contained in:
2025-05-05 11:31:46 +08:00
parent eea4a4ce9f
commit b9dcc83c39
24 changed files with 688 additions and 244 deletions

View File

@@ -1,13 +1,24 @@
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::ops::Deref;
use ecow::EcoString;
use derive_more::Constructor;
use ecow::EcoString;
#[derive(Clone, Debug, PartialEq, Constructor)]
pub struct Catchable {
msg: Option<String>,
}
impl Display for Catchable {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
if let Some(ref msg) = self.msg {
write!(f, "<error: {msg}>")
} else {
write!(f, "<error>")
}
}
}
#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Constructor)]
pub struct Symbol(EcoString);
@@ -17,6 +28,12 @@ impl<T: Into<EcoString>> From<T> for Symbol {
}
}
impl Display for Symbol {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
write!(f, r#"Sym({})"#, self.0)
}
}
impl Deref for Symbol {
type Target = str;
fn deref(&self) -> &Self::Target {