* Switched to stable Rust instead of nightly.

* Updated to latest published version of Embassy.
* Updated to stable release of embedded-hal.
* Version bump other dependencies.
* Changed examples to use stm32 blackpill.
This commit is contained in:
Zachary Sunforge
2024-02-13 21:32:09 -08:00
parent ef7de3baad
commit 8a7e32b8ca
11 changed files with 72 additions and 84 deletions

View File

@ -15,7 +15,8 @@ pub enum CriticalError {
}
impl CriticalError {
pub fn emergency_procedure(self, procedure: impl FnOnce(CriticalError) -> !) -> ! {
//TODO: Switch to using ! as the return type for the FnOnce and the entire function when the ! feature is stabilized
pub fn emergency_procedure(self, procedure: impl FnOnce(CriticalError)) {
procedure(self);
}
}
@ -24,18 +25,24 @@ impl CriticalError {
pub trait CriticalErrResult: Copy {
type Value: Copy;
//TODO: Switch to using ! as the return type for the FnOnce when the ! feature is stabilized
/// Execute emergency procedure in the event of a critical, the emergency procedure cannot
/// return. It should usually terminate the program, potentially rebooting the device in some sort of recovery mode.
fn err_emproc(self, procedure: impl FnOnce(CriticalError) -> !) -> Self::Value;
fn err_emproc(self, procedure: impl FnOnce(CriticalError)) -> Self::Value;
}
impl<T: Copy> CriticalErrResult for Result<T, CriticalError> {
type Value = T;
fn err_emproc(self, procedure: impl FnOnce(CriticalError) -> !) -> Self::Value {
//TODO: Switch to using ! as the return type for the FnOnce when the ! feature is stabilized
fn err_emproc(self, procedure: impl FnOnce(CriticalError)) -> Self::Value {
match self {
Ok(val) => val,
Err(error) => error.emergency_procedure(procedure),
Err(error) => {
error.emergency_procedure(procedure);
//TODO: Remove this panic when we switch to ! return type
panic!()
},
}
}
}