Skip to content

Provide From<E> for Box<dyn Error + Send> and Box<dyn Error + Sync> #62824

Open
@dodomorandi

Description

@dodomorandi

As explained in the Rust User forum, I noticed that the following impls are not available:

impl<'a, E: Error + Send + 'a> From<E> for Box<dyn Error + Send + 'a> {}
impl<'a, E: Error + Sync + 'a> From<E> for Box<dyn Error + Sync + 'a> {}

The first one is pretty useful when working with rayon and errors, which only need to be Send to be passed across threads. In theory, a stateful error with a Cell or a RefCell is a possible example of dyn Error + Send + !Sync.

The second impl is mainly for coherence and symmetry, I still do not have in mind a possible realistic situation.

In any case, IMHO this feature should not require a RFC. In that case I can create a PR and follow these steps:

  • Implement the two impls
  • Adjust the docs

It is the first time I contribute to Rust, and I am not sure if this feature should require a stabilization process. In this case just let me know, and I will update this document in order to include the addition of a feature gate and everything needed.

Any feedback is appreciated to make me do things nicely and your review less painful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions