use crate::{Expression, Identifier, Node, NodeID, Statement, TypeNode};
use leo_span::Span;
use serde::Serialize;
use std::fmt;
#[derive(Clone, Default, PartialEq, Eq, Hash, Serialize, Debug)]
pub struct ConstDeclaration {
pub is_exported: Option<bool>,
pub place: Identifier,
pub type_: TypeNode,
pub value: Expression,
pub span: Span,
pub id: NodeID,
}
impl fmt::Display for ConstDeclaration {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.is_exported == Some(true) {
write!(f, "export ")?;
}
write!(f, "const {}: {} = {}", self.place, self.type_, self.value)
}
}
impl From<ConstDeclaration> for Statement {
fn from(value: ConstDeclaration) -> Self {
Statement::Const(value)
}
}
crate::simple_node_impl!(ConstDeclaration);