Closed plaes closed 3 years ago
Good point.
Most HAL's I've worked with define an extension trait on u32
in their prelude (e.g. stm32f4xx-hal)
The concrete type of the timeout value will depend on the implementation of CountDown.
core::time::Duration
would be one possible type but often (especially with no-std
) other types are used.
I would like to keep the .ms()
call since it doesn't mention a concrete type, but maybe we could provide our own extension trait such as:
use core::time::Duration;
pub trait U64Ext {
fn ms(self) -> Duration;
}
impl U64Ext for u64 {
fn ms(self) -> Duration {
Duration::from_millis(self)
}
}
Would that work for you?
Yeah, having these would be excellent, as I was trying to use it without HAL (or with basic linux-embedded-hal) and couldn't figure out where to import these definitions (see issue #2 ).
When attempting to use the examples, code like this:
pn532.process(&Request::INLIST_ONE_ISO_A_TARGET, 7, 1000.ms());
Causes errors:
can't call method
mson ambiguous numeric type
{integer}``Should these changed to use
std::time::Duration::from_millis()
instead?