1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2023-2024 The Regents of the University of California
// released under BSD 3-Clause License
// author: Kevin Laeufer <laeufer@berkeley.edu>

use crate::{WidthInt, Word};
use smallvec::SmallVec;

type ValueVec = SmallVec<[Word; 1]>;

/// Owned value.
pub struct Value {
    width: WidthInt,
    words: ValueVec,
}

/// Abstracts over values no matter how they are stored.
trait ValueKind {
    fn width(&self) -> WidthInt;
    fn words(&self) -> &[Word];
}

impl ValueKind for Value {
    fn width(&self) -> WidthInt {
        self.width
    }

    fn words(&self) -> &[Word] {
        &self.words
    }
}