Skip to content

Commit

Permalink
implement TryFrom for Value container
Browse files Browse the repository at this point in the history
  • Loading branch information
ekiwi committed Oct 21, 2024
1 parent d009c61 commit a6e3210
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,27 @@ pub enum Value {
BitVec(BitVecValue),
}

impl TryFrom<Value> for ArrayValue {
type Error = ();

fn try_from(value: Value) -> Result<Self, Self::Error> {
match value {
Value::Array(v) => Ok(v),
Value::BitVec(_) => Err(()),
}
}
}

impl TryFrom<Value> for BitVecValue {
type Error = ();

fn try_from(value: Value) -> Result<Self, Self::Error> {
match value {
Value::BitVec(v) => Ok(v),
Value::Array(_) => Err(()),
}
}
}

pub use array::*;
pub use bv::*;

0 comments on commit a6e3210

Please sign in to comment.