openvm_native_compiler/ir/
select.rs

1use crate::ir::{Builder, Config, Ext, Felt, Var};
2
3pub trait CanSelect<C: Config> {
4    fn select(builder: &mut Builder<C>, cond: Var<C::N>, a: Self, b: Self) -> Self;
5}
6
7impl<C: Config> CanSelect<C> for Var<C::N> {
8    fn select(builder: &mut Builder<C>, cond: Var<C::N>, a: Self, b: Self) -> Self {
9        builder.select_v(cond, a, b)
10    }
11}
12
13impl<C: Config> CanSelect<C> for Felt<C::F> {
14    fn select(builder: &mut Builder<C>, cond: Var<C::N>, a: Self, b: Self) -> Self {
15        builder.select_f(cond, a, b)
16    }
17}
18
19impl<C: Config> CanSelect<C> for Ext<C::F, C::EF> {
20    fn select(builder: &mut Builder<C>, cond: Var<C::N>, a: Self, b: Self) -> Self {
21        builder.select_ef(cond, a, b)
22    }
23}