diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-06-13 07:22:04 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-06-13 07:22:04 +0000 |
| commit | db685c04049449ac3e4f256f2e7e26dad550d94c (patch) | |
| tree | f4ec5de70ec05e793a774049e010935ac45853ed /examples/std/src/serial_port.rs | |
| parent | fff0a03fe0f9e84209dd40fd8f93790871d03d75 (diff) | |
| parent | a8703b75988e1e700af701116464025679d2feb8 (diff) | |
Merge #808
808: Add rustfmt.toml with some nice settings. r=lulf a=Dirbaio
Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'examples/std/src/serial_port.rs')
| -rw-r--r-- | examples/std/src/serial_port.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/examples/std/src/serial_port.rs b/examples/std/src/serial_port.rs index 6825cbebc..c41abd4d0 100644 --- a/examples/std/src/serial_port.rs +++ b/examples/std/src/serial_port.rs | |||
| @@ -1,18 +1,16 @@ | |||
| 1 | use std::io; | ||
| 2 | use std::os::unix::io::{AsRawFd, RawFd}; | ||
| 3 | |||
| 1 | use nix::errno::Errno; | 4 | use nix::errno::Errno; |
| 2 | use nix::fcntl::OFlag; | 5 | use nix::fcntl::OFlag; |
| 3 | use nix::sys::termios; | 6 | use nix::sys::termios; |
| 4 | use std::io; | ||
| 5 | use std::os::unix::io::{AsRawFd, RawFd}; | ||
| 6 | 7 | ||
| 7 | pub struct SerialPort { | 8 | pub struct SerialPort { |
| 8 | fd: RawFd, | 9 | fd: RawFd, |
| 9 | } | 10 | } |
| 10 | 11 | ||
| 11 | impl SerialPort { | 12 | impl SerialPort { |
| 12 | pub fn new<P: ?Sized + nix::NixPath>( | 13 | pub fn new<P: ?Sized + nix::NixPath>(path: &P, baudrate: termios::BaudRate) -> io::Result<Self> { |
| 13 | path: &P, | ||
| 14 | baudrate: termios::BaudRate, | ||
| 15 | ) -> io::Result<Self> { | ||
| 16 | let fd = nix::fcntl::open( | 14 | let fd = nix::fcntl::open( |
| 17 | path, | 15 | path, |
| 18 | OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, | 16 | OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, |
