Skip to content

Commit 45e7f74

Browse files
committed
Add bool conversions for u1
1 parent 04d5c32 commit 45e7f74

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/conversion.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,24 @@ implement_from!(i62, [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15,
299299
implement_from!(i63, [i2, i3, i4, i5, i6, i7, i9, i10, i11, i12, i13, i14, i15, i17, i18, i19, i20, i21, i22, i23, i24, i25, i26, i27, i28, i29, i30, i31,
300300
i33, i34, i35, i36, i37, i38, i39, i40, i41, i42, i43, i44, i45, i46, i47, i48, i49, i50, i51, i52, i53, i54, i55, i56, i57, i58, i59, i60, i61, i62]);
301301

302+
impl From<bool> for u1 {
303+
fn from(b: bool) -> Self {
304+
match b {
305+
true => u1(1),
306+
false => u1(0),
307+
}
308+
}
309+
}
310+
311+
impl From<u1> for bool {
312+
fn from(u1(x): u1) -> Self {
313+
match x {
314+
0 => false,
315+
1 => true,
316+
_ => unreachable!(),
317+
}
318+
}
319+
}
302320

303321
#[cfg(test)]
304322
mod tests {

0 commit comments

Comments
 (0)