Skip to content

Commit

Permalink
Merge pull request #2362 from kpp/ternary_impl_box
Browse files Browse the repository at this point in the history
Add impl Ternary for Box<T: Ternary>
  • Loading branch information
howardwu authored Feb 20, 2024
2 parents 1cebaaf + 7b42092 commit 0f9e500
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
10 changes: 0 additions & 10 deletions circuit/account/src/signature/ternary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ impl<A: Aleo> Ternary for Signature<A> {
}
}

impl<A: Aleo> Ternary for Box<Signature<A>> {
type Boolean = Boolean<A>;
type Output = Box<Signature<A>>;

/// Returns `first` if `condition` is `true`, otherwise returns `second`.
fn ternary(condition: &Self::Boolean, first: &Self, second: &Self) -> Self::Output {
Box::new(Signature::ternary(condition, first, second))
}
}

impl<A: Aleo> Metrics<dyn Ternary<Boolean = Boolean<A>, Output = Signature<A>>> for Signature<A> {
type Case = (Mode, Mode, Mode);

Expand Down
10 changes: 0 additions & 10 deletions console/account/src/signature/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,3 @@ impl<N: Network> Ternary for Signature<N> {
}
}
}

impl<N: Network> Ternary for Box<Signature<N>> {
type Boolean = Boolean<N>;
type Output = Self;

/// Returns `first` if `condition` is `true`, otherwise returns `second`.
fn ternary(condition: &Self::Boolean, first: &Self, second: &Self) -> Self::Output {
Box::new(Signature::ternary(condition, first, second))
}
}
10 changes: 10 additions & 0 deletions console/network/environment/src/traits/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,13 @@ pub trait Ternary {
where
Self: Sized;
}

impl<T: Ternary> Ternary for Box<T> {
type Boolean = T::Boolean;
type Output = Box<T::Output>;

/// Returns `first` if `condition` is `true`, otherwise returns `second`.
fn ternary(condition: &Self::Boolean, first: &Self, second: &Self) -> Self::Output {
Box::new(T::ternary(condition, first, second))
}
}

0 comments on commit 0f9e500

Please sign in to comment.