Add std::io::cursor::WriteThroughCursor#158537
Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
So, I'm not sure this PR itself is worthwhile separating from #158541, since it appears that you move this trait into That is also the largest PR of the bunch post-split, and I wonder if it should be further split up into parts, rather than this being the only "part" split off of it. |
|
I've started a conversation about this matter on Zulip since it's probably better suited for workshopping a solution. Linking here for transparency. |
|
|
||
| #[stable(feature = "cursor_mut_vec", since = "1.25.0")] | ||
| impl<A> Write for Cursor<&mut Vec<u8, A>> | ||
| impl<A> WriteThroughCursor for &mut Vec<u8, A> |
There was a problem hiding this comment.
So, main concern is this unfortunately isn't going to be shown under the implementations for Write, and I'm not really sure what the best way to deal with that is. rustdoc doesn't really seem to have a method to create "fake" impls for docs only, so maybe there should be some kind of issue tracking a way to deal with this.
There was a problem hiding this comment.
Yeah I think there would need to be some kind of "flatten" feature for listing implementations. Ignoring instability for a moment, adding this trait would hide the Write implementations for:
Cursor<&mut Vec<u8, A>> where A: AllocatorCursor<Vec<u8, A>> where A: AllocatorCursor<Box<[u8], A>> where A: Allocator
And would instead show:
Cursor<T> where T: WriteThroughCursor
Which would require users to visit WriteThroughCursor to see it is implemented for:
&mut Vec<u8, A>Vec<u8, A>Box<[u8], A>
Ideally, we could do something like:
#[doc(flatten = "T")]
impl<T: WriteThroughCursor> Write for Cursor<T> { /* ... */ }To recreate the original flat documentation.
86ea27a to
bb3669b
Compare
|
r? @clarfonthey (happy to take the review but as you mentioned elsewhere might make sense to batch-review a bunch of these PRs) |
Used to work around `Cursor` not being a fundamental type when implementing `Write` for `Cursor<Vec<u8>>` and other `alloc` types once `Cursor` and `Write` are both located in `core`.
bb3669b to
cae0245
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
I think that the discussion from Zulip was compelling enough that we can merge this separately; essentially, this technically changes the behaviour of implementations and can be useful for bisection in case of issues, even though the actual code will show up as completely moved on diffs. Given that this does not conflict with other @bors r+ rollup=iffy Marking as rollup=iffy mostly for visibility with the other |
…uwer Rollup of 12 pull requests Successful merges: - #156976 (enable eager `param_env` norm in new solver) - #158537 (Add `std::io::cursor::WriteThroughCursor`) - #158540 (Move `std::io::Seek` to `core::io`) - #157820 (consider subtyping when checking if an infer var is sized) - #158505 (Update POSIX edition links) - #158853 (Fix typo for link on nto-qnx.md) - #157466 (Better error message when bare type in impl parameter list) - #157966 (Emit a suggestion to cast the never type into a concrete type when it fails to satisfy an `impl Trait` bound) - #158381 (Expose debug scope of statement and terminator in rustc_public) - #158405 (rustc_target: Add ARMv8-M related target features) - #158770 (Weaken guarantee for `From<legacy::RangeInclusive> for RangeInclusive`) - #158820 (Fix rustdoc ICE on deprecated note in inlined re-export chain)
Rollup merge of #158537 - bushrat011899:std_io_write_through_cursor, r=clarfonthey Add `std::io::cursor::WriteThroughCursor` ACP: rust-lang/libs-team#755 Tracking issue: #154046 Split From: #156527 ## Description Used to work around `Cursor` not being a fundamental type when implementing `Write` for `Cursor<Vec<u8>>` and other `alloc` types once `Cursor` and `Write` are both located in `core`. Please refer to #156527 for further context. --- ## Notes * No AI tooling of any kind was used during the creation of this PR. * Please see #154046 (comment) for a review order and broader context for this PR.
ACP: rust-lang/libs-team#755
Tracking issue: #154046
Split From: #156527
Description
Used to work around
Cursornot being a fundamental type when implementingWriteforCursor<Vec<u8>>and otheralloctypes onceCursorandWriteare both located incore. Please refer to #156527 for further context.Notes
alloc::ioandcore::io#154046 (comment) for a review order and broader context for this PR.