Skip to content

Feature request: make ParserSpan ~Copyable. #13

Open
@CrystDragon

Description

@CrystDragon

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions