Skip to content

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

Closed
@pomoke

Description

@pomoke

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