Skip to content

ArrayExt trait #168

Description

@tarcieri

We currently have AsArrayRef and AsArrayMut traits. #167 noted as_array_mut is inconsistent with core::slice's as_mut_array.

The issue made me think perhaps we should have more general and extensible extension traits, something like:

  • ArrayExt
  • ArrayMutExt (or MutArrayExt?) (unnecessary, just put mut methods on `ArrayExt)
  • SliceExt implemented
  • SliceMutExt (or MutSliceExt?) (unnecessary)

The existing AsArrayRef/AsArrayMut are impl'd for both Array and core [T; N]. The idea is ArrayExt/ArrayMutExt could also be impl'd for both, and SliceExt/SliceMutExt could be impl'd for core [T].

We already provide some methods for slice conversions as Array::slice_* (which should probably stay there so they can be const fn), but it would be nice to have those directly callable from core slices via Slice(Mut)Ext.

An important question is what naming scheme do we use so we can provide parallel methods to core but which operate on hybrid_array::Array instead of core's [T; N]?

In #167 I suggested we could so something like SliceExt::as_harray to disambiguate from [T]::as_array. A wrapper for our existing Array::slice_as_chunks could perhaps be SliceExt::as_hchunks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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