Skip to content

Commit 131d7e9

Browse files
committed
Remove mention of impl Receiver for Vec
Since Vec already implements Deref.
1 parent 5cec046 commit 131d7e9

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

text/3519-arbitrary-self-types-v2.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -608,27 +608,9 @@ A previous PR based on the `Deref` alternative has been proposed before https://
608608

609609
As [discussed above](#pick-shadowed-methods-instead-of-erroring) we anticipate a future version which will relax some errors into warnings, and thus allow us to add support for raw pointers, `Weak` and `NonNull` as self types.
610610

611-
Thereafter, we could consider implementing `Receiver` for other types, e.g. [`std::cell`](https://doc.rust-lang.org/std/cell/index.html) types, [`std::sync`](https://doc.rust-lang.org/std/sync/index.html) types, [`std::cmp::Reverse`](https://doc.rust-lang.org/std/cmp/struct.Reverse.html), [`std::num::Wrapping`](https://doc.rust-lang.org/nightly/std/num/struct.Wrapping.html), [`std::mem::MaybeUninit`](https://doc.rust-lang.org/std/mem/union.MaybeUninit.html), [`std::task::Poll`](https://doc.rust-lang.org/nightly/std/task/enum.Poll.html), and so on - possibly even for arrays, `Vec`, `BTreeSet` etc.
611+
Thereafter, we could consider implementing `Receiver` for other types, e.g. [`std::cell`](https://doc.rust-lang.org/std/cell/index.html) types, [`std::sync`](https://doc.rust-lang.org/std/sync/index.html) types, [`std::cmp::Reverse`](https://doc.rust-lang.org/std/cmp/struct.Reverse.html), [`std::num::Wrapping`](https://doc.rust-lang.org/nightly/std/num/struct.Wrapping.html), [`std::mem::MaybeUninit`](https://doc.rust-lang.org/std/mem/union.MaybeUninit.html), [`std::task::Poll`](https://doc.rust-lang.org/nightly/std/task/enum.Poll.html), and so on - possibly even for arrays, etc.
612612

613-
There seems to be no disadvantage to doing this - taking `Vec` as an example, it would only have any effect on the behavior of code if somebody implemented a method taking `Vec<T>` as a receiver. On the other hand, it's hard to imagine use-cases for some of these. It seems best to consider these future possibilities based on whether the end-result seems natural or strange.
614-
615-
```rust
616-
impl Vexation {
617-
fn do_something_to_vec(self: Vec<Self>) { }
618-
fn do_something_to_maybeuninit(self: MaybeUninit<Self>) {}
619-
}
620-
621-
fn main {
622-
let mut v = Vec::new();
623-
v.push(Vexation);
624-
v.do_something_to_vec(); // this seems weird and I can't imagine a use-case
625-
626-
let mut m = MaybeUninit::<Vexation>::uninit();
627-
m.do_something_to_maybeuninit(); // this seems fine and useful and so maybe we should in future implement Receiver for MaybeUninit
628-
}
629-
```
630-
631-
For now, though, we should clearly restrict `Receiver` to those types for which there's a demonstrated need.
613+
There seems to be no disadvantage to doing this - taking `Cell` as an example, it would only have any effect on the behavior of code if somebody implemented a method taking `Cell<T>` as a receiver. On the other hand, it's hard to imagine use-cases for some of these. For now, though, we should clearly restrict `Receiver` to those types for which there's a demonstrated need.
632614

633615
# Feature gates
634616

0 commit comments

Comments
 (0)