Skip to main content

oxilean_codegen/python_backend/
pythonparam_traits.rs

1//! # PythonParam - Trait Implementations
2//!
3//! This module contains trait implementations for `PythonParam`.
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::PythonParam;
14use std::fmt;
15
16impl fmt::Display for PythonParam {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        if self.is_vararg {
19            write!(f, "*")?;
20        } else if self.is_kwarg {
21            write!(f, "**")?;
22        }
23        write!(f, "{}", self.name)?;
24        if let Some(ann) = &self.annotation {
25            write!(f, ": {}", ann)?;
26        }
27        if let Some(default) = &self.default {
28            write!(f, " = {}", default)?;
29        }
30        Ok(())
31    }
32}