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

Remove trait inheritance from CheckedAdd/Sub/Mul/Div #12275

Closed
Closed
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
12 changes: 8 additions & 4 deletions src/libstd/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,13 @@ pub trait Primitive: Clone
pub trait Int: Integer
+ Primitive
+ Bitwise
+ Add<Self, Self>
+ CheckedAdd
+ Sub<Self, Self>
+ CheckedSub
+ Mul<Self, Self>
// + CheckedMul // FIXME #8849: currently not impled on 32-bit
+ Div<Self, Self>
+ CheckedDiv {}

/// Returns the smallest power of 2 greater than or equal to `n`.
Expand Down Expand Up @@ -1054,19 +1058,19 @@ impl<T: CheckedAdd + CheckedSub + Zero + Ord + Bounded> Saturating for T {
}
}

pub trait CheckedAdd: Add<Self, Self> {
pub trait CheckedAdd {
fn checked_add(&self, v: &Self) -> Option<Self>;
}

pub trait CheckedSub: Sub<Self, Self> {
pub trait CheckedSub {
fn checked_sub(&self, v: &Self) -> Option<Self>;
}

pub trait CheckedMul: Mul<Self, Self> {
pub trait CheckedMul {
fn checked_mul(&self, v: &Self) -> Option<Self>;
}

pub trait CheckedDiv: Div<Self, Self> {
pub trait CheckedDiv {
fn checked_div(&self, v: &Self) -> Option<Self>;
}

Expand Down