Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a marker trait for equality testing #131

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ pub trait ConstantTimeEq {
}
}

/// A marker trait indicating that `Eq` equality testing uses `ConstantTimeEq` under the hood.
///
/// Even though `Eq`-based equality testing returns a `bool`, it's a common design pattern
/// to have some types implement this using `ConstantTimeEq`, and then coerce the resulting
/// `Choice` into a `bool`.
///
/// This marker trait should be used if and only if you do this, in order to signal this
/// functionality to implementers.
pub trait EqIsConstantTimeEq {}

impl<T: ConstantTimeEq> ConstantTimeEq for [T] {
/// Check whether two slices of `ConstantTimeEq` types are equal.
///
Expand Down
Loading