Skip to content

Commit 01c6ca7

Browse files
committed
Add future work section for MaybeUninit etc.
1 parent 7ea82bd commit 01c6ca7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,30 @@ Even if the reader takes the view that all calls into foreign languages are intr
555555

556556
A previous PR based on the `Deref` alternative has been proposed before https://github.com/rust-lang/rfcs/pull/2362 and was postponed with the expectation that the lang team would [get back to `arbitrary_self_types` eventually](https://github.com/rust-lang/rfcs/pull/2362#issuecomment-527306157).
557557

558+
# Future work
559+
560+
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.
561+
562+
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.
563+
564+
```rust
565+
impl Vexation {
566+
fn do_something_to_vec(self: Vec<Self>) { }
567+
fn do_something_to_maybeuninit(self: MaybeUninit<Self>) {}
568+
}
569+
570+
fn main {
571+
let v = Vec::new();
572+
v.push(Vexation);
573+
v.do_something_to_vec(); // this seems weird and I can't imagine a use-case
574+
575+
let mut m = MaybeUninit::<Vexation>::uninit();
576+
m.do_something_to_maybeuninit(); // this seems fine and useful and so maybe we should in future implement Receiver for MaybeUninit
577+
}
578+
```
579+
580+
For now, though, we should clearly restrict `Receiver` to those types for which there's a demonstrated need.
581+
558582
# Feature gates
559583

560584
This RFC is in an unusual position regarding feature gates. There are two existing gates:

0 commit comments

Comments
 (0)