snarkvm_circuit_environment::traits

Trait Ternary

Source
pub trait Ternary {
    type Boolean;
    type Output;

    // Required method
    fn ternary(
        condition: &Self::Boolean,
        first: &Self,
        second: &Self,
    ) -> Self::Output
       where Self: Sized;
}
Expand description

Trait for ternary operations.

Required Associated Types§

Required Methods§

Source

fn ternary( condition: &Self::Boolean, first: &Self, second: &Self, ) -> Self::Output
where Self: Sized,

Returns first if condition is true, otherwise returns second.

Implementations on Foreign Types§

Source§

impl<E> Ternary for Boolean<E>
where E: Environment,

Source§

fn ternary( condition: &<Boolean<E> as Ternary>::Boolean, first: &Boolean<E>, second: &Boolean<E>, ) -> <Boolean<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Boolean<E>

Source§

impl<E> Ternary for Field<E>
where E: Environment,

Source§

fn ternary( condition: &<Field<E> as Ternary>::Boolean, first: &Field<E>, second: &Field<E>, ) -> <Field<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Field<E>

Source§

impl<E> Ternary for Group<E>
where E: Environment,

Source§

fn ternary( condition: &<Group<E> as Ternary>::Boolean, first: &Group<E>, second: &Group<E>, ) -> <Group<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Group<E>

Source§

impl<E> Ternary for Scalar<E>
where E: Environment,

Source§

fn ternary( condition: &<Scalar<E> as Ternary>::Boolean, first: &Scalar<E>, second: &Scalar<E>, ) -> <Scalar<E> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Scalar<E>

Source§

impl<E, I> Ternary for Integer<E, I>
where E: Environment, I: IntegerType,

Source§

fn ternary( condition: &<Integer<E, I> as Ternary>::Boolean, first: &Integer<E, I>, second: &Integer<E, I>, ) -> <Integer<E, I> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = Boolean<E>

Source§

type Output = Integer<E, I>

Source§

impl<T> Ternary for Box<T>
where T: Ternary,

Source§

fn ternary( condition: &<Box<T> as Ternary>::Boolean, first: &Box<T>, second: &Box<T>, ) -> <Box<T> as Ternary>::Output

Returns first if condition is true, otherwise returns second.

Source§

type Boolean = <T as Ternary>::Boolean

Source§

type Output = Box<<T as Ternary>::Output>

Implementors§