-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
replace BitAndAssign
example with something more evocative
#35927
Conversation
Like discussed on IRC, please write simpler examples. |
Copy-pasting the IRC discussion here. I'd link to the logs, but I can't prevent them from truncating prematurely. https://gist.github.com/matthew-piziak/a2dd18e897eb3d4113459a945d85296b |
I like this example, however it's not clear what should happen if the use std::ops::BitAndAssign;
#[derive(Debug, PartialEq)]
struct BooleanVector {
value: [bool; 4],
}
impl BitAndAssign for BooleanVector {
fn bitand_assign(&mut self, rhs: Self) {
for (x, y) in self.value.iter_mut().zip(&rhs.value) {
*x &= *y;
}
}
}
fn main() {
let mut bv = BooleanVector { value: [true, true, false, false] };
bv &= BooleanVector { value: [true, false, true, false] };
let expected = BooleanVector { value: [true, false, false, false] };
assert_eq!(bv, expected);
} |
This pull request is based on the discussion in PR rust-lang#35927. Add a module-level note that `&&` and `||` are short-circuiting operators and not overloadable. Add a simple `Scalar` example that lifts the `&` operator to a trivial struct tuple. Make `BooleanVector` a struct tuple. Derive `PartialEq` for `BooleanVector` instead of implementing it. Adds a `fn main` wrapper so that the example can integrate with Rust Playground. simplified bitand expression add a comment explaining what "rhs" means
…=GuillaumeGomez improve `BitAnd` trait documentation This pull request is based on the discussion in PR rust-lang#35927. Add a module-level note that `&&` and `||` are short-circuiting operators and not overloadable. Add a simple `Scalar` example that lifts the `&` operator to a trivial struct tuple. Make `BooleanVector` a struct tuple. Derive `PartialEq` for `BooleanVector` instead of implementing it. Adds a `fn main` wrapper so that the example can integrate with Rust Playground.
I've taken the improvements in #35993 and applied them to this PR. I figured that a simple |
…=GuillaumeGomez improve `BitAnd` trait documentation This pull request is based on the discussion in PR rust-lang#35927. Add a module-level note that `&&` and `||` are short-circuiting operators and not overloadable. Add a simple `Scalar` example that lifts the `&` operator to a trivial struct tuple. Make `BooleanVector` a struct tuple. Derive `PartialEq` for `BooleanVector` instead of implementing it. Adds a `fn main` wrapper so that the example can integrate with Rust Playground.
@bors retry |
…=GuillaumeGomez improve `BitAnd` trait documentation This pull request is based on the discussion in PR rust-lang#35927. Add a module-level note that `&&` and `||` are short-circuiting operators and not overloadable. Add a simple `Scalar` example that lifts the `&` operator to a trivial struct tuple. Make `BooleanVector` a struct tuple. Derive `PartialEq` for `BooleanVector` instead of implementing it. Adds a `fn main` wrapper so that the example can integrate with Rust Playground.
…=GuillaumeGomez improve `BitAnd` trait documentation This pull request is based on the discussion in PR rust-lang#35927. Add a module-level note that `&&` and `||` are short-circuiting operators and not overloadable. Add a simple `Scalar` example that lifts the `&` operator to a trivial struct tuple. Make `BooleanVector` a struct tuple. Derive `PartialEq` for `BooleanVector` instead of implementing it. Adds a `fn main` wrapper so that the example can integrate with Rust Playground.
This is the augmented-assignment version of PR rust-lang#35809. r? @GuillaumeGomez improved documentation a la PR rust-lang#35993
dadab30
to
ba69bc8
Compare
Thanks! @bors: r+ rollup |
📌 Commit ba69bc8 has been approved by |
…, r=GuillaumeGomez replace `BitAndAssign` example with something more evocative This is the augmented-assignment version of PR rust-lang#35809. r? @GuillaumeGomez
This is the augmented-assignment version of PR #35809.
r? @GuillaumeGomez