Commit 3e92550
Merge #643
643: Implement `PeekingNext` transitively over mutable references. r=jswrenn a=olson-sean-k
This PR allows `PeekingNext` to be used as a trait object just like `Iterator`, allowing code to accept types like `&mut dyn PeekingNext<Item = T>` for some item type `T`. To accomplish this, generic methods now require that `Self: Sized` and `PeekingNext` now has a transitive implementation over mutable references to types that implement `PeekingNext`.
This mirrors the design of the `Iterator` trait ([here](https://doc.rust-lang.org/nightly/src/core/iter/traits/iterator.rs.html#776-782) and [here](https://doc.rust-lang.org/nightly/src/core/iter/traits/iterator.rs.html), for example). See also [this discussion on the Rust internals forum](https://internals.rust-lang.org/t/generic-methods-over-object-safe-traits/6774).
Co-authored-by: Sean Olson <[email protected]>1 file changed
+12
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
20 | 31 | | |
21 | 32 | | |
22 | 33 | | |
| |||
0 commit comments