Skip to main content

oxilean_codegen/dart_backend/
dartannotation_traits.rs

1//! # DartAnnotation - Trait Implementations
2//!
3//! This module contains trait implementations for `DartAnnotation`.
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_args, fmt_typed_params};
14use super::types::DartAnnotation;
15use std::fmt;
16
17impl fmt::Display for DartAnnotation {
18    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19        match self {
20            DartAnnotation::Override => write!(f, "@override"),
21            DartAnnotation::Deprecated => write!(f, "@deprecated"),
22            DartAnnotation::VisibleForTesting => write!(f, "@visibleForTesting"),
23            DartAnnotation::Immutable => write!(f, "@immutable"),
24            DartAnnotation::Sealed => write!(f, "@sealed"),
25            DartAnnotation::Custom(name, args) => {
26                if args.is_empty() {
27                    write!(f, "@{}", name)
28                } else {
29                    write!(f, "@{}({})", name, args.join(", "))
30                }
31            }
32        }
33    }
34}