pub trait CtCheckedAdd: Sized {
// Required method
fn ct_checked_add(&self, v: &Self) -> CtOption<Self>;
}Available on crate feature
ct only.Expand description
Constant-time checked addition (the masked counterpart of
CheckedAdd).
Required Methods§
Sourcefn ct_checked_add(&self, v: &Self) -> CtOption<Self>
fn ct_checked_add(&self, v: &Self) -> CtOption<Self>
Computes self + v, returning a CtOption that is None-masked
on overflow.
use const_num_traits::ops::ct::CtCheckedAdd;
assert_eq!(250u8.ct_checked_add(&5).unwrap(), 255);
assert!(bool::from(255u8.ct_checked_add(&1).is_none()));Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".