diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2019-07-13 16:55:08 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2019-07-26 11:19:14 +0200 |
| commit | bf3ec3be3e595780d842ac3069bb07f3c50f54b8 (patch) | |
| tree | f77ff990d44133e29c96ef03f825d9a9e1f46db1 /example/mini_core.rs | |
| parent | 92f2b6243d717b6ff711fdf9fe9d579d41669ee1 (diff) | |
| download | rust-bf3ec3be3e595780d842ac3069bb07f3c50f54b8.tar.gz rust-bf3ec3be3e595780d842ac3069bb07f3c50f54b8.zip | |
Implement checked binops
Diffstat (limited to 'example/mini_core.rs')
| -rw-r--r-- | example/mini_core.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/example/mini_core.rs b/example/mini_core.rs index d900776c55c..8c372450abd 100644 --- a/example/mini_core.rs +++ b/example/mini_core.rs @@ -128,6 +128,14 @@ impl Add for u8 { } } +impl Add for i8 { + type Output = Self; + + fn add(self, rhs: Self) -> Self { + self + rhs + } +} + impl Add for usize { type Output = Self; @@ -151,6 +159,30 @@ impl Sub for usize { } } +impl Sub for u8 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +impl Sub for i8 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + +impl Sub for i16 { + type Output = Self; + + fn sub(self, rhs: Self) -> Self { + self - rhs + } +} + #[lang = "bitor"] pub trait BitOr<RHS = Self> { type Output; @@ -270,6 +302,22 @@ pub trait Neg { fn neg(self) -> Self::Output; } +impl Neg for i8 { + type Output = i8; + + fn neg(self) -> i8 { + -self + } +} + +impl Neg for i16 { + type Output = i16; + + fn neg(self) -> i16 { + -self + } +} + impl Neg for isize { type Output = isize; |
