Skip to content

Trait bounds of read_multiple() cannot be reproduced in downstream code #40

@Rahix

Description

@Rahix

From #39 (comment).

It is currently not possible to write a generic function in downstream code which calls read_multiple() with matching trait bounds. The problem is that some of the traits used by read_multiple() are internal to port-expander. We should find a way to fix this.

Motivating example which currently does not work:

fn poll_external_io<'a, PD, MUTEX, MODE: port_expander::mode::HasInput>(
    motion_sensor: &mut MotionSensor,
    estop_gpio: &port_expander::Pin<'a, MODE, MUTEX>,
    sensor_gpio: &port_expander::Pin<'a, MODE, MUTEX>,
) where
    PD: port_expander::PortDriver,
    MUTEX: port_expander::PortMutex<Port = PD>,
{
    let read = port_expander::read_multiple([estop_gpio, sensor_gpio]);
    todo!()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions