Skip to main content

litex/obj/
atomic_name.rs

1use crate::common::keywords::MOD_SIGN;
2use std::fmt;
3
4// Used for prop predicate and struct names.
5#[derive(Clone, PartialEq, Eq)]
6pub enum AtomicName {
7    WithoutMod(String),
8    WithMod(String, String), // mod_name, name
9}
10
11impl fmt::Display for AtomicName {
12    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13        match self {
14            AtomicName::WithoutMod(name) => write!(f, "{}", name),
15            AtomicName::WithMod(mod_name, name) => {
16                write!(f, "{}{}{}", mod_name, MOD_SIGN, name)
17            }
18        }
19    }
20}