Skip to content

advance_mut implementation of BufMut for Vec<u8> seems inconsistent with documentation #354

Closed
@udoprog

Description

@udoprog

The documentation of BufMut::advance_mut states the following about panics:

Panics

This function may panic if cnt > self.remaining_mut().

Implementer notes

It is recommended for implementations of advance_mut to panic if
cnt > self.remaining_mut(). If the implementation does not panic,
the call must behave as if cnt == self.remaining_mut().

A call with cnt == 0 should never panic and be a no-op.

Currently, the impl for Vec<u8> will reserve to accommodate the advance. This seems to be in conflict with If the implementation does not panic, the call must behave as if cnt == self.remaining_mut().

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