Skip to content

i2c trait Error type has no bounds #84

Closed
@LunNova

Description

@LunNova

Is it intentional that there are no bounds on the associated Error types for the i2c traits?

As they are not guaranteed to implement anything, it doesn't seem to be possible to make a custom Error type which can implement From for them in a useful way.

It would be nice to be able to write code like this:

fn frob_foos(read: &mut impl Read, write: &mut impl Write) -> Result<bool, MyErrorType???> {
    write.write(ADDR, &[6, 0])?;
    write.write(ADDR, &[7, 0xFF])?;
    write.write(ADDR, &[2, 0x55])?;
    write.write(ADDR, &[0])?;
    let mut buf = [0u8];
    read.read(ADDR, &mut buf)?;
    // ...
}

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