miden_assembly_syntax/ast/
visibility.rs

1use core::fmt;
2
3// ITEM VISIBILITY
4// ================================================================================================
5
6/// Represents the visibility of an item (procedure, constant, etc.) globally.
7#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Hash)]
8#[repr(u8)]
9pub enum Visibility {
10    /// The item is visible outside its defining module
11    Public = 0,
12    /// The item is visible only within its defining module
13    #[default]
14    Private = 1,
15}
16
17impl fmt::Display for Visibility {
18    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
19        if self.is_public() { f.write_str("pub") } else { Ok(()) }
20    }
21}
22
23impl Visibility {
24    /// Returns true if the current item has public visibility
25    pub fn is_public(&self) -> bool {
26        matches!(self, Self::Public)
27    }
28}