oxilean_std/term_rewriting/term_traits.rs
1//! # Term - Trait Implementations
2//!
3//! This module contains trait implementations for `Term`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Display`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use super::types::Term;
12use std::fmt;
13
14impl std::fmt::Display for Term {
15 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16 match self {
17 Term::Var(i) => write!(f, "x{}", i),
18 Term::Fun(name, args) => {
19 if args.is_empty() {
20 write!(f, "{}", name)
21 } else {
22 write!(
23 f,
24 "{}({})",
25 name,
26 args.iter()
27 .map(|a| a.to_string())
28 .collect::<Vec<_>>()
29 .join(", ")
30 )
31 }
32 }
33 }
34 }
35}