Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Error trait for type Error<Data> where Data is not Display #691

Closed
@pomoke

Description

Error trait is crucial in usage like converting error to something like Anyhow::Error,which can be used to propagate errors simply. Some functions use Error<()>, but unit type is not Display, so it will not have Error trait.

A workaround looks like this, which requires manual conversion of error.

let serial = bs.open_protocol_exclusive::<Serial>(serial_handle).map_err(|x| anyhow!("Failed to open serial protocol, status {}",x.status()))?;

Due to implementation of a trait cannot overlap, simply do impl<Data: Debug> Display for Error<Data> will not work.

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

        AltStyle によって変換されたページ (->オリジナル) /