1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
use Secret; pub trait Cond { fn cond(&self) -> bool; } impl Cond for bool { fn cond(&self) -> bool {*self} } impl<A> Cond for Secret<bool, A> { fn cond(&self) -> bool {self.val} } /// Helps converting a condition type into `bool`. pub fn cond_eval<T: Cond>(a: &T) -> bool { a.cond() }