Skip to content

FromBytes::(mut_)?slice_from_[prefix|suffix] also returns the prefix/suffix instead of just the read slice #884

Closed
@kupiakos

Description

@kupiakos
  • slice_from_prefix returns Option<(&[Self], &[u8])>
  • slice_from_suffix returns Option<(&[u8], &[Self])>
  • mut_slice_from_prefix returns Option<(&mut [Self], &mut [u8])>
  • mut_slice_from_suffix returns Option<(&mut [u8], &mut [Self])>

However, all of the other methods drop the prefix/suffix:

  • FromBytes::read_from_prefix returns Option<Self>
  • FromBytes::read_from_suffix returns Option<Self>
  • FromBytes::ref_from_prefix returns Option<&Self>
  • FromBytes::ref_from_suffix returns Option<&Self>
  • FromBytes::mut_from_prefix returns Option<&mut Self>
  • FromBytes::mut_from_suffix returns Option<&mut Self>

This is desirable: the majority of the time I drop the prefix anyways and these are convenience methods for methods in Ref.
[ref|mut]_from_[prefix|suffix] in their docs both point to using Ref to preserve the prefix/suffix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatibility-breakingChanges that are (likely to be) breakingcustomer-requestDocuments customer requests.documentationImprovements or additions to documentationexperience-easyThis issue is easy, and shouldn't require much experiencegood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions