-
Notifications
You must be signed in to change notification settings - Fork 246
Closed
Milestone
Description
From<bool>
is already implemented for PinState in digital.rs
, which makes sense for output pins. For input pins, it would make sense to implement the Into<bool>
trait as well, so a function could take an argument that is either a PinState
or a bool
:
impl Into<bool> for PinState {
fn into(self) -> bool {
match self {
PinState::Low => false,
PinState::High => true,
}
}
}
fn print_state<T: Into<bool>>(state: T) {
println!("{:?}", state.into());
}
fn main() {
print_state(false);
print_state(true);
print_state(PinState::Low);
print_state(PinState::High);
}
MathiasKoch
Metadata
Metadata
Assignees
Labels
No labels