smtlib_lowlevel/
storage.rs1use bumpalo::Bump;
2
3use crate::ast::Term;
4
5#[derive(Debug)]
6pub struct Storage {
7 arena: Bump,
8}
9
10impl PartialEq for Storage {
11 fn eq(&self, other: &Self) -> bool {
12 std::ptr::eq(&self.arena, &other.arena)
13 }
14}
15
16impl Eq for Storage {}
17
18impl Storage {
19 pub fn new() -> Storage {
20 Storage { arena: Bump::new() }
21 }
22 pub fn alloc<T>(&self, item: T) -> &T {
23 self.arena.alloc(item)
24 }
25 pub fn alloc_slice<'a, T: Clone>(&'a self, items: &[T]) -> &'a [T] {
26 self.arena.alloc_slice_clone(items)
27 }
28 pub fn alloc_str<'a>(&'a self, src: &str) -> &'a str {
29 self.arena.alloc_str(src)
31 }
32 pub fn alloc_term<'a>(&'a self, term: Term<'a>) -> &'a Term<'a> {
33 self.alloc(term)
34 }
35}
36
37impl Default for Storage {
38 fn default() -> Self {
39 Self::new()
40 }
41}