Skip to main content

anodized_core/
qualifiers.rs

1use bitflags::bitflags;
2
3bitflags! {
4    /// A combination of `fn` qualifiers.
5    #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6    pub struct FnQualifiers: u32 {
7        /// A deterministic `fn`'s return value depends only on its arguments.
8        const DETERMINISTIC = 1 << 0;
9
10        /// An effectfree `fn` has no side effects.
11        const EFFECTFREE = 1 << 1;
12
13        /// An infallible `fn` does not panic or abort.
14        const INFALLIBLE = 1 << 2;
15
16        /// A terminating `fn` does not run forever.
17        const TERMINATING = 1 << 3;
18
19        /// A pure `fn` is both deterministic and effectfree.
20        const PURE = Self::DETERMINISTIC.bits() | Self::EFFECTFREE.bits();
21
22        /// A total `fn` is both infallible and terminating.
23        const TOTAL = Self::INFALLIBLE.bits() | Self::TERMINATING.bits();
24
25        /// A functional `fn` is both pure and total.
26        const FUNCTIONAL = Self::PURE.bits() | Self::TOTAL.bits();
27    }
28}