Skip to main content

oxilean_codegen/opt_dce/
constvalue_traits.rs

1//! # ConstValue - Trait Implementations
2//!
3//! This module contains trait implementations for `ConstValue`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Display`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use crate::lcnf::*;
12
13use super::types::ConstValue;
14use std::fmt;
15
16impl fmt::Display for ConstValue {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        match self {
19            ConstValue::Lit(lit) => write!(f, "const({})", lit),
20            ConstValue::Ctor(name, tag, args) => {
21                write!(f, "ctor({}#{}", name, tag)?;
22                for a in args {
23                    write!(f, " {}", a)?;
24                }
25                write!(f, ")")
26            }
27            ConstValue::Unknown => write!(f, "unknown"),
28        }
29    }
30}