Skip to content

Commit

Permalink
Add conversion from bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Remco Bloemen committed Oct 16, 2020
1 parent a4fbf23 commit 342e014
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions algebra/u256/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ impl<'a> Deserialize<'a> for U256 {
}
}

impl From<bool> for U256 {
fn from(n: bool) -> Self {
if n {
U256::one()
} else {
U256::zero()
}
}
}

macro_rules! impl_from_uint {
($type:ty) => {
impl From<$type> for U256 {
Expand Down

0 comments on commit 342e014

Please sign in to comment.