Tracking Issue for `core_io_borrowed_buf`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Feature gate: #![feature(core_io_borrowed_buf)]
This is a tracking issue for an MVP of core::io, which contains an OS-independent subset of std::io.
Public API
The initial API of this module consists of BorrowedBuf and BorrowedCursor, which were previously only available in std.
Steps / History
- https://github.com/rust-lang/rust/pull/97015
- https://github.com/rust-lang/rust/pull/117694
- Final comment period (FCP)^1
- Stabilization PR
See also: https://github.com/rust-lang/rust/issues/78485
Unresolved Questions
- Now that it's generic (#149749) double-check any bounds we might want before stabilization
- For example, it used to always be
Debug(which was easy sinceu8: Debug), but for generic do we want always-Debugor only forT: Debug?
- For example, it used to always be
Naming:
-
BorrowedCursor::writtenneeds renaming tobuf_written(implementation work only) https://github.com/rust-lang/rust/issues/117693#issuecomment-5106705125 -
core::ioorcore::mem? https://github.com/rust-lang/rust/issues/117693#issuecomment-5156999054, #t-libs > `io::BorrowedBuf` or `mem::BorrowedBuf` - Should
BorrowedCursorbe renamed toBorrowedWriter? It's more similar toBufWriterthanCursorhttps://github.com/rust-lang/rust/issues/117693#issuecomment-5182654686, #t-libs > Why is it called `io::BorrowedCursor`? - General name confusion, specifically
read_bufhttps://github.com/rust-lang/rust/issues/117693#issuecomment-5207802573 (Concern 5)
Documentation:
- All API is missing examples, some is missing tests (implementation work only) https://github.com/rust-lang/rust/issues/117693#issuecomment-5109936825 / https://github.com/rust-lang/rust/issues/117693#issuecomment-5160382935
- General documentation issues: needs to clarify why these two types exist rather than being combined https://github.com/rust-lang/rust/issues/117693#issuecomment-5182654686, what exists is confusing and methods are not in useful order https://github.com/rust-lang/rust/issues/117693#issuecomment-5207802573 (concern 1)
API confusion:
-
BorrowedCursor::capacityindicates remaining capacity rather than total capacity, unlikeVechttps://github.com/rust-lang/rust/issues/117693#issuecomment-5170391734 - Feature split with
borrowed_buf_initis confusing:advanceandadvance_checkedare split, affectsas_muthttps://github.com/rust-lang/rust/issues/117693#issuecomment-5173597407, https://github.com/rust-lang/rust/issues/117693#issuecomment-5207802573 (concern 3) - Do we need both
into_filledandinto_filled_mut? https://github.com/rust-lang/rust/issues/117693#issuecomment-5173650638 - Should we add inherent constructors to avoid inference issues? (Not blocking) https://github.com/rust-lang/rust/issues/117693#issuecomment-5183461507
- Should we have
is_empty? (Not blocking) https://github.com/rust-lang/rust/issues/117693#issuecomment-5260411124 - Unnecessary return of
selfhttps://github.com/rust-lang/rust/issues/117693#issuecomment-5207802573 -
writtenconfusion,positionas an alternative https://github.com/rust-lang/rust/issues/117693#issuecomment-5359723201
Variance:
- We have
BorrowedCursor<'data>, which would be invariant, but make it covariant with a lot ofunsafe. This is fragile compared toBorrowedCursor<'buf, 'data>https://github.com/rust-lang/rust/issues/117693#issuecomment-5180050759, https://github.com/rust-lang/rust/issues/117693#issuecomment-5208964609, #t-libs > Why is it called `io::BorrowedCursor`? @ 💬
Trait and bounds:
- Should we print the filled portion during
Debug? We don't haveT: Debugin the current impl https://github.com/rust-lang/rust/issues/117693#issuecomment-5173759271 - Needless gates on
T: Copyhttps://github.com/rust-lang/rust/issues/117693#issuecomment-5207802573
Other:
- This API has been contentious: confirm it is what we want over something like #t-libs > `buffer-trait` would overlap with `BorrowedBuf`
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the core::io feature gate and the public APIs BorrowedBuf and BorrowedCursor, then read the unresolved questions and linked discussion. The tracking issue lists naming, documentation, API, variance, and trait concerns that require resolution before stabilization. Done means the remaining decisions are resolved and a stabilization PR is prepared.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100