1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright (c) 2016-2021 Fabian Schuiki

#![allow(missing_docs)]

use crate::arenas::{Alloc, AllocOwned};
use crate::konst2::*;

make_arenas!(
    /// An arena to allocate constant values into.
    pub struct ConstArena<'t> {
        integer: IntegerConst<'t>,
        floating: FloatingConst<'t>,
    }
);

impl<'t> AllocOwned<'t, 't, Const2<'t>> for ConstArena<'t> {
    fn alloc_owned(&'t self, value: OwnedConst<'t>) -> &'t Const2<'t> {
        match value {
            OwnedConst::Integer(k) => self.alloc(k),
            OwnedConst::Floating(k) => self.alloc(k),
        }
    }
}