-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Allow T op= &T for built-in numeric types T v2 #44287
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
fn main() { | ||
// test compound assignment operators with ref as right-hand side, | ||
// for each operator, with various types as operands. | ||
|
||
// test AddAssign | ||
{ | ||
let mut x = 3i8; | ||
x += &2i8; | ||
assert_eq!(x, 5i8); | ||
} | ||
|
||
// test SubAssign | ||
{ | ||
let mut x = 7i16; | ||
x -= &4; | ||
assert_eq!(x, 3i16); | ||
} | ||
|
||
// test MulAssign | ||
{ | ||
let mut x = 3f32; | ||
x *= &3f32; | ||
assert_eq!(x, 9f32); | ||
} | ||
|
||
// test DivAssign | ||
{ | ||
let mut x = 6f64; | ||
x /= &2f64; | ||
assert_eq!(x, 3f64); | ||
} | ||
|
||
// test RemAssign | ||
{ | ||
let mut x = 7i64; | ||
x %= &4i64; | ||
assert_eq!(x, 3i64); | ||
} | ||
|
||
// test BitOrAssign | ||
{ | ||
let mut x = 0b1010u8; | ||
x |= &0b1100u8; | ||
assert_eq!(x, 0b1110u8); | ||
} | ||
|
||
// test BitAndAssign | ||
{ | ||
let mut x = 0b1010u16; | ||
x &= &0b1100u16; | ||
assert_eq!(x, 0b1000u16); | ||
} | ||
|
||
// test BitXorAssign | ||
{ | ||
let mut x = 0b1010u32; | ||
x ^= &0b1100u32; | ||
assert_eq!(x, 0b0110u32); | ||
} | ||
|
||
// test ShlAssign | ||
{ | ||
let mut x = 0b1010u64; | ||
x <<= &2u32; | ||
assert_eq!(x, 0b101000u64); | ||
} | ||
|
||
// test ShrAssign | ||
{ | ||
let mut x = 0b1010u64; | ||
x >>= &2i16; | ||
assert_eq!(x, 0b10u64); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing trailing newline There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I fix now or wait for cargobomb? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Eh2406 Cargobomb uses the compiler already built from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will need to be
"1.22.0"
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed, thanks!