| Age | Commit message (Collapse) | Author | Lines |
|
Add impls for `&Wrapping`. Also `Sum`, `Product` impls for both `Wrapping` and `&Wrapping`.
There are two changes here (split into two commits):
- Ops for references to `&Wrapping` (`Add`, `Sub`, `Mul` etc.) similar to the way they are implemented for primitives.
- Impls for `iter::{Sum,Product}` for `Wrapping`.
As far as I know `impl` stability attributes don't really matter so I didn't bother breaking up the macro for two different kinds of stability. Happy to change if it does matter.
|
|
Elide lifetimes in DerefMut documentation
- Elide lifetimes to increase the readability of `DerefMut` examples
|
|
- Elide lifetimes to increase the readability
of `DerefMut` examples
|
|
Fix a few links in the docs
r? @steveklabnik
|
|
Fix typo in the BitAndAssign operator documentation
The name of the operator should be `&=` instead of `&`.
|
|
|
|
|
|
|
|
|
|
Add missing urls for ops module
Part of #29365.
r? @steveklabnik
|
|
|
|
Use examples and placeholder variable names with more meaning, to not
make it so abstract.
|
|
demonstrate `RHS != Self` use cases for `Add` and `Sub`
|
|
|
|
replace `BitAndAssign` example with something more evocative
This is the augmented-assignment version of PR #35809.
r? @GuillaumeGomez
|
|
add evocative examples for `BitOr` and `BitXor`
These are exactly equivalent to PR #35809, with one caveat: I do not believe there is a non-bitwise binary XOR operator in Rust, so here it's expressed as `(a || b) && !(a && b)`.
Alternative decompositions are `(a && !b) || (!a && b)` and `(a || b) && (!a || !b)`. Let me know if you think one of those would be clearer.
r? @GuillaumeGomez
|
|
This is the augmented-assignment version of PR #35809.
r? @GuillaumeGomez
improved documentation a la PR #35993
|
|
These are exactly equivalent to PR #35809, with one caveat: I do not believe there is a non-bitwise binary "xor" operator in Rust, so here it's expressed as (a || b) && !(a && b).
r? @GuillaumeGomez
improved documentation a la PR #35993
|
|
improve `BitAnd` trait documentation
This pull request is based on the discussion in PR #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.
|
|
add evocative examples for `Shl` and `Shr`
r? @steveklabnik
|
|
improve documentation for `Fn*` traits
This PR is not yet a serious attempt at contribution. Rather, I'm opening this for discussion. I can think of a few things we may want to accomplish with the documentation of the `Fn`, `FnMut`, and `FnOnce` traits:
- the relationship between these traits and the closures that implement them
- examples of non-closure implementations
- the relationship between these traits and Rust's ownership semantics
|
|
r=steveklabnik
show how iterating over `RangeTo` and `RangeToInclusive` fails
Feedback on PR #35701 seems to be positive, so this does the same thing for `RangeTo` and `RangeToInclusive`.
|
|
remove extra `../`s
|
|
This pull request is based on the discussion in PR #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
|
|
Use `#[prelude_import]` in `libcore` and `libstd`
r? @eddyb
|
|
|
|
more evocative examples for `Sub` and `SubAssign`
These examples are exactly analogous to those in PRs #35709 and #35806. I'll probably remove the `fn main` wrappers for `Add` and `Sub` once this is merged in.
Part of #29365.
r? @steveklabnik
|
|
r? @steveklabnik
add examples that lift `<<` and `>>` to a trivial struct
replace `Scalar` structs with struct tuples
add `fn main` wrappers to enable Rust Playground "Run" button
|
|
Analogous to PR #35860.
r? @GuillaumeGomez
|
|
I can think of a few things we may want to accomplish with the documentation of the `Fn`, `FnMut`, and `FnOnce` traits:
- the relationship between these traits and the closures that implement them
- examples of non-closure implementations
- the relationship between these traits and Rust's ownership semantics
add module-level documentation for `Fn*` traits
Describe how `Fn*` traits, closure types, and ownership semantics are
linked, and provide examples of higher-level functions that take `Fn*`s.
more examples for `Fn*` traits
create correct (though not yet elegant) examples for `FnMut` and `FnOnce`
add trait links to module-level documentation
third time's a charm!
argument -> capture for trait documentation
This wording will need to be supported with better examples for
capturing eventually.
correct `FnOnce` example
I also fixed some of the trait wording here to make the concept of
capturing clearer; though that still needs more work.
replace `x + x` with `x * 2` for `fn double`
|
|
replace `Index` example with something more evocative of indexing
r? @steveklabnik
|
|
replace `Rem` example with something more evocative
r? @steveklabnik
|
|
replace `Mul` example with something more evocative of multiplication
I may have gone a bit overboard on this one. Numbers are fun.
|
|
replace `BitAnd` example with something more evocative of bitwise AND
|
|
These examples are exactly analogous to those in PRs #35709 and #35806. I'll probably remove the `fn main` wrappers for `Add` and `Sub` once this is merged in.
Part of #29365.
r? @steveklabnik
|
|
reformat method chain according to ubsan Rustic Style Guide
https://ubsan.github.io/style/
|
|
I may have gone a bit overboard on this one. Numbers are fun.
tone down the error message
|
|
Carrier trait (third attempt)
This adds a `Carrier` trait to operate with `?`. The only public implementation is for `Result`, so effectively the trait does not exist, however, it ensures future compatibility for the `?` operator. This is not intended to be used, nor is it intended to be a long-term solution.
Although this exact PR has not been through Crater, I do not expect it to be a breaking change based on putting numerous similar PRs though Crater in the past.
cc:
* [? tracking issue](https://github.com/rust-lang/rust/issues/31436)
* [previous PR](https://github.com/rust-lang/rust/pull/35056)
* [RFC issue](https://github.com/rust-lang/rfcs/issues/1718) for discussion of long-term Carrier trait solutions.
r? @nikomatsakis
|
|
r? @steveklabnik
|
|
r? @steveklabnik
|
|
Feedback on PR #35701 seems to be positive, so this does the same thing for `RangeTo` and `RangeToInclusive`.
|
|
replace `Neg` example with something more evocative of negation
|
|
replace `Not` example with something more evocative
|
|
replace `AddAssign` example with something more evocative of addition
This is analogous to PR #35709 for the `Add` trait.
|
|
demonstrate `RHS != Self` use cases for `Mul` and `Div`
Vector-scalar multipication is a good usecase for this. Thanks #rust!
|
|
note that calling drop() explicitly is a compiler error
Part of #29365
|
|
replace `Add` example with something more evocative of addition
Currently most of the operator traits use trivial implementation
examples that only perform side effects. Honestly, that might not be too
bad for the sake of documentation; but anyway, here's a proposal to move
a slightly modified version of the module-level point-addition example
into the `Add` documentation, since it's more evocative of addition
semantics.
Part of #29365
|
|
explicitly show how iterating over `..` fails
I've also removed the `main()` wrapper, which I believe is extraneous.
LMK if that's incorrect.
|
|
|
|
|