FluenTech / embedded-time

Time(ing) library (Instant/Duration/Clock/Timer/Period/Frequency) for bare-metal embedded systems
Apache License 2.0
87 stars 17 forks source link

Remaining/Elapsed timer calculation for generic clock #125

Open marius-meissner opened 2 years ago

marius-meissner commented 2 years ago

The following example is failing by unsatisfied trait bounds:

use embedded_time::{Clock};
use embedded_time::duration::{Microseconds};

fn test<C: Clock>(clock: C)
{
    let duration = Microseconds::new(100);
    let timer = clock.new_timer(duration).start().unwrap();
    timer.remaining();
}

Are there further trait bound required? I tried already some compiler suggestions, without success. I would be very grateful for a brief hint in the right direction. Maybe this information could help others later on.

Thanks in advance!

Version: v0.12.1 @ rustc 1.60.0-nightly (88fb06a1f 2022-02-05)

rmja commented 1 year ago

Year, I have the same problem...

rmja commented 1 year ago

I guess you need:


fn test<C: Clock>(clock: C) where C::T: Into<u32> {
}