Skip to main content

oxilean_std/static_analysis/
interval_traits.rs

1//! # Interval - Trait Implementations
2//!
3//! This module contains trait implementations for `Interval`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Display`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use super::types::Interval;
12use std::fmt;
13
14impl std::fmt::Display for Interval {
15    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16        match self {
17            Interval::Bottom => write!(f, "⊥"),
18            Interval::Range(lo, hi) => {
19                let l = if *lo == i64::MIN {
20                    "-∞".to_string()
21                } else {
22                    lo.to_string()
23                };
24                let r = if *hi == i64::MAX {
25                    "+∞".to_string()
26                } else {
27                    hi.to_string()
28                };
29                write!(f, "[{}, {}]", l, r)
30            }
31        }
32    }
33}