IoSlice
: the Deref
impl is too restrictive on the lifetime of the slice, an alternative is needed.
#124659
Labels
C-bug
Category: This is a bug.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
I tried code similar to the following to advance an
std::io::IoSlice
(playground link):This does not compile, yielding the following error:
The issue is that the
Defer<Target = [u8]>
impl onIoSlice
discards the'static
lifetime, replacing it with the lifetime of the ofbuf
.However, we should be able to write such code using only safe Rust: all we are doing is effectively storing a subslice of the original buffer. For example, if we replace
IoSlice
with normal slices&[u8]
it compiles:To make
IoSlice
more flexible there should be a method which returns a slice with the same lifetime of the underlying memory, something similar to the following:Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: