-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
Feature gate: #![feature(io_slice_const)]
This is a tracking issue for making the new and advance methods on IoSlice and IoSliceMut const.
In particular, this enables constructing IoSlice and IoSliceMut in const contexts without users needing to break the platform abstraction by doing the cast themselves. This is useful for statics.
Since all current and plausible future platforms use simple slice-like structs, this should not impose a burden when adding a new platform with a different struct.
Public API
Methods new and advance are made const for IoSlice and IoSliceMut. advance_slices is more complicated and remains non-const. into_slice/as_slice are unstably const and tracked separately.
// std::io
impl<'a> IoSliceMut<'a> {
#[rustc_const_unstable(feature = "io_slice_const", issue = "146459")]
pub const fn new(buf: &'a mut [u8]) -> IoSliceMut<'a>;
#[rustc_const_unstable(feature = "io_slice_const", issue = "146459")]
pub const fn advance(&mut self, n: usize;
// Other methods (unchanged):
pub fn advance_slices(bufs: &mut &mut [IoSliceMut<'a>], n: usize);
#[unstable(feature = "io_slice_as_bytes", issue = "132818")]
pub const fn into_slice(self) -> &'a mut [u8];
}
impl<'a> IoSlice<'a> {
#[rustc_const_unstable(feature = "io_slice_const", issue = "146459")]
pub const fn new(buf: &'a [u8]) -> IoSlice<'a>;
#[rustc_const_unstable(feature = "io_slice_const", issue = "146459")]
pub const fn advance(&mut self, n: usize);
// Other methods (unchanged):
pub fn advance_slices(bufs: &mut &mut [IoSlice<'a>], n: usize);
#[unstable(feature = "io_slice_as_bytes", issue = "132818")]
pub const fn as_slice(self) -> &'a [u8];
}Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- Implementation: Make
IoSliceandIoSliceMutmethods unstably const #144090 - Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- None yet.
Footnotes
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.