From 9e75cec551429719da2f84b2f40eeaaecbf7f3cd Mon Sep 17 00:00:00 2001 From: Victor Koenders Date: Tue, 18 Jan 2022 11:17:01 +0100 Subject: [PATCH] Added `impl Default` for UartConfig --- rp2040-hal/src/uart/utils.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/rp2040-hal/src/uart/utils.rs b/rp2040-hal/src/uart/utils.rs index ba6b455..e44011b 100644 --- a/rp2040-hal/src/uart/utils.rs +++ b/rp2040-hal/src/uart/utils.rs @@ -59,6 +59,16 @@ pub enum Parity { } /// A struct holding the configuration for an UART device. +/// +/// The `Default` implementation implements the following values: +/// ``` +/// UartConfig { +/// baudrate: Baud(0), +/// data_bits: DataBits::Eight, +/// stop_bits: StopBits::One, +/// parity: None, +///} +/// ``` #[non_exhaustive] pub struct UartConfig { /// The baudrate the uart will run at. @@ -74,6 +84,17 @@ pub struct UartConfig { pub parity: Option, } +impl Default for UartConfig { + fn default() -> Self { + Self { + baudrate: Baud(0), + data_bits: DataBits::Eight, + stop_bits: StopBits::One, + parity: None, + } + } +} + /// Same as core::convert::Infallible, but implementing serial::Error /// /// For eh 1.0.0-alpha.6, Infallible doesn't implement serial::Error,