Skip to main content

gc_lite/
helpers.rs

1#[derive(Debug, Clone, PartialEq, Eq)]
2pub enum GcError {
3    /// Memory allocation failed
4    AllocationFailed,
5    /// Invalid reference
6    InvalidReference,
7    /// Partition is full
8    PartitionFull,
9    /// Partition not found
10    PartitionNotFound,
11    /// Partition is not empty
12    PartitionNotEmpty,
13}
14
15pub type GcResult<T> = Result<T, GcError>;
16
17#[inline(always)]
18pub(crate) const fn unlikely(expr: bool) -> bool {
19    if expr {
20        #[cold]
21        const fn cold_path() -> bool {
22            true
23        }
24        cold_path()
25    } else {
26        false
27    }
28}
29
30#[macro_export]
31macro_rules! gc_type_register {
32    ( $( $ty:ty $(, drop_pass = $pass:expr)?; )+ ) => {
33        $crate::gc_type_table_internal! {
34            crate_path = $crate;
35            $( $ty $(, drop_pass = $pass)?; )+
36        }
37    };
38}