Skip to main content

oxilean_codegen/scala_backend/
scalaobject_traits.rs

1//! # ScalaObject - Trait Implementations
2//!
3//! This module contains trait implementations for `ScalaObject`.
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::ScalaObject;
14use std::fmt;
15
16impl fmt::Display for ScalaObject {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        write!(f, "object {}", self.name)?;
19        if !self.extends_list.is_empty() {
20            write!(f, " extends {}", self.extends_list[0])?;
21            for e in &self.extends_list[1..] {
22                write!(f, " with {}", e)?;
23            }
24        }
25        write!(f, " {{")?;
26        for (name, ty, expr) in &self.constants {
27            write!(f, "\n  val {}: {} = {}", name, ty, expr)?;
28        }
29        for m in &self.methods {
30            write!(f, "\n  {}", m)?;
31        }
32        write!(f, "\n}}")
33    }
34}