-
Notifications
You must be signed in to change notification settings - Fork 24
Add back BorrowedBuf::filled_mut #139
Copy link
Copy link
Closed
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Metadata
Metadata
Assignees
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Type
Fields
Give feedbackNo fields configured for issues without a type.
Proposal
Problem statement
The current
BorrowedBufAPI has no way to modify the filled data without using unsafe. This blocks several use cases:filledbuf.Motivation, use-cases
Need to mutate the initialized buffer for various reasons.
Solution sketches
See rust-lang/rust#103754. TL;DR: add
Links and related work
filled_mutwas part of the original RFC, but was removed during the split into BorrowedBuf and BorrowedCursor. The cited rationale is to make BorrowedBuf read-only and BorrowedCursor write-only. I don't believe this logic holds up for a number of reasons:filled_mut.filled_mutdoes not weaken the guarantees made by BorrowedBuf in any way.BorrowedBuf(which can be annoying for a number of reasons) and manually convert the underlying MaybeUninit buffer to initialized u8s using unsafe.