-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! This example does not actually do anything, but it shows that a serialport | ||
//! instance can be passed to functions / drivers that expect a type that | ||
//! implements the embedded-hal traits. | ||
|
||
use embedded_hal_nb::serial; | ||
|
||
fn take_reader<R: serial::Read<u8>>(_r: &R) { | ||
// do nothing, but things should typecheck | ||
} | ||
|
||
fn take_writer<W: serial::Write<u8>>(_w: &W) { | ||
// do nothing, but things should typecheck | ||
} | ||
|
||
fn main() { | ||
let port = serialport::new("/dev/null", 9600) | ||
.open() | ||
.expect("This example isn't meant for running. It just demonstrates compatibility with embedded-hal on a type level."); | ||
take_reader(&port); | ||
take_writer(&port); | ||
} |