Skip to main content

oxilean_codegen/ruby_backend/
rubycasein_traits.rs

1//! # RubyCaseIn - Trait Implementations
2//!
3//! This module contains trait implementations for `RubyCaseIn`.
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::functions::{fmt_ruby_class, fmt_ruby_method, fmt_ruby_module_stmt, fmt_ruby_stmt};
14use super::types::RubyCaseIn;
15use std::fmt;
16
17impl std::fmt::Display for RubyCaseIn {
18    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19        writeln!(f, "case {}", self.scrutinee)?;
20        for (pat, body) in &self.arms {
21            writeln!(f, "in {}", pat)?;
22            writeln!(f, "  {}", body)?;
23        }
24        if let Some(els) = &self.else_body {
25            writeln!(f, "else")?;
26            writeln!(f, "  {}", els)?;
27        }
28        write!(f, "end")
29    }
30}