Merge pull request #268 from VictorKoenders/default-uart-config

Added `impl Default` for UartConfig
This commit is contained in:
Jonathan 'theJPster' Pallant 2022-01-18 20:50:01 +00:00 committed by GitHub
commit 3a0e23c406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,6 +59,17 @@ pub enum Parity {
}
/// A struct holding the configuration for an UART device.
///
/// The `Default` implementation implements the following values:
/// ```ignore
/// # // can't actually create this with the non_exhaustive attribute
/// UartConfig {
/// baudrate: Baud(115_200),
/// data_bits: DataBits::Eight,
/// stop_bits: StopBits::One,
/// parity: None,
///}
/// ```
#[non_exhaustive]
pub struct UartConfig {
/// The baudrate the uart will run at.
@ -74,6 +85,17 @@ pub struct UartConfig {
pub parity: Option<Parity>,
}
impl Default for UartConfig {
fn default() -> Self {
Self {
baudrate: Baud(115_200),
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,