mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
dsl: implement Display for Value
This commit is contained in:
parent
faecc2c304
commit
632977a0dc
1 changed files with 15 additions and 0 deletions
|
|
@ -189,6 +189,21 @@ pub const fn to_digit (c: char) -> DslResult<usize> {
|
|||
Exp(usize, TokenIter<'source>),
|
||||
}
|
||||
|
||||
impl<'source> std::fmt::Display for Value<'source> {
|
||||
fn fmt (&self, out: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||
write!(out, "{}", match self {
|
||||
Nil => String::new(),
|
||||
Err(e) => format!("[error: {e}]"),
|
||||
Num(n) => format!("{n}"),
|
||||
Sym(s) => format!("{s}"),
|
||||
Key(s) => format!("{s}"),
|
||||
Str(s) => format!("{s}"),
|
||||
Exp(_, e) => format!("{e:?}"),
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'source> Token<'source> {
|
||||
pub const fn new (
|
||||
source: &'source str, start: usize, length: usize, value: Value<'source>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue