Skip to content

Implement support for Box<[T]> and Arc<[T]> #633

Open
@nazar-pc

Description

@nazar-pc

Arc<[T]> is especially helpful in cases where something needs to be sent into a different thread, but cloning and double indirection are undesirable.

Right now both fail something like this:

error[E0277]: the trait bound `[subspace_core_primitives::pieces::PieceIndex]: parity_scale_codec::WrapperTypeDecode` is not satisfied
  --> crates/subspace-networking/src/protocols/request_response/handlers/cached_piece_by_index.rs:28:24
   |
28 |     pub cached_pieces: Box<[PieceIndex]>,
   |                        ^^^^^^^^^^^^^^^^^ the trait `parity_scale_codec::WrapperTypeDecode` is not implemented for `[subspace_core_primitives::pieces::PieceIndex]`, which is required by `std::boxed::Box<[subspace_core_primitives::pieces::PieceIndex]>: parity_scale_codec::Decode`
   |
   = help: the following other types implement trait `parity_scale_codec::WrapperTypeDecode`:
             std::boxed::Box<T>
             std::rc::Rc<T>
             std::sync::Arc<T>
   = note: required for `[subspace_core_primitives::pieces::PieceIndex]` to implement `parity_scale_codec::Decode`
   = note: 1 redundant requirement hidden
   = note: required for `std::boxed::Box<[subspace_core_primitives::pieces::PieceIndex]>` to implement `parity_scale_codec::Decode`

I'm not 100% sure, but suspect it is an upstream issue since downstream users will not be able to implement WrapperTypeDecode for Box<[T]> or Arc<[T]>.

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