We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eb2e93c commit 52dfc48Copy full SHA for 52dfc48
examples/embedded_hal.rs
@@ -0,0 +1,21 @@
1
+//! This example does not actually do anything, but it shows that a serialport
2
+//! instance can be passed to functions / drivers that expect a type that
3
+//! implements the embedded-hal traits.
4
+
5
+use embedded_hal_nb::serial;
6
7
+fn take_reader<R: serial::Read<u8>>(_r: &R) {
8
+ // do nothing, but things should typecheck
9
+}
10
11
+fn take_writer<W: serial::Write<u8>>(_w: &W) {
12
13
14
15
+fn main() {
16
+ let port = serialport::new("/dev/null", 9600)
17
+ .open()
18
+ .expect("This example isn't meant for running. It just demonstrates compatibility with embedded-hal on a type level.");
19
+ take_reader(&port);
20
+ take_writer(&port);
21
0 commit comments