RustCrypto / RustCrypto/hybrid-array

`ArrayExt` trait

Open
#168 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
23
Forks
25
Avg merge
1h 46m
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing AsArrayRef and AsArrayMut traits and the Array::slice_* methods, then compare their APIs with the corresponding core slice and array methods. The issue needs a settled naming scheme and scope before implementation; done means the agreed extension traits and parallel methods are specified and consistently implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.