Open
Description
Currently, ParserSpan
is Copyable
, it is OK because the documentation says it's
A non-owning, non-escaping view for parsing binary data.
However, that means client code can use it this way:
extension QOI.Header {
init(parsing input: inout ParserSpan) throws {
var sharedCopy = input
self.channels = try Channels(parsing: &input)
self.colorspace = try ColorSpace(parsing: &sharedCopy)
}
}
In this snippet, both input
and sharedCopy
are referencing the same underline bytes, however they are distinct. The user might think they can be used interchangeably, which is not the case.
I think changing ParserSpan
into representing exclusive references can help reduce such confusion.
Metadata
Metadata
Assignees
Labels
No labels