Skip to content

Commit

Permalink
implement conversion from bit vec ref to owned
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Sep 17, 2024
1 parent 42e16cd commit a6ffb75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "baa"
version = "0.9.4"
version = "0.9.5"
edition = "2021"
authors = ["Kevin Laeufer <laeufer@cornell.edu>"]
description = "BitVector and Array Arithmetic"
Expand Down
8 changes: 7 additions & 1 deletion src/value/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use crate::io::strings::ParseIntError;
use crate::ops::{ArrayMutOps, ArrayOps};
use crate::{BitVecMutOps, BitVecOps, WidthInt, Word};
use crate::{BitVecMutOps, BitVecOps, BitVecValueRef, WidthInt, Word};
use smallvec::{smallvec, SmallVec};

pub(crate) type ValueVec = SmallVec<[Word; 2]>;
Expand Down Expand Up @@ -103,6 +103,12 @@ impl From<bool> for BitVecValue {
}
}

impl<'a> From<BitVecValueRef<'a>> for BitVecValue {
fn from(value: BitVecValueRef<'a>) -> Self {
Self::new(value.width, SmallVec::from_slice(value.words))
}
}

/// Owned dense bit-vector array.
#[derive(Clone)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
Expand Down

0 comments on commit a6ffb75

Please # to comment.