diff options
author | 2021-12-31 17:50:41 +0000 | |
---|---|---|
committer | 2021-12-31 17:50:41 +0000 | |
commit | cde498dab4fbae0bbf093046dc2ae196ce4308d5 (patch) | |
tree | 124f84fc0fca7b5cc46535dd2bed17a0700d69f8 /xtask/src | |
parent | 42065a6864a00f9f7d47fe8fd123c2f175362d37 (diff) | |
parent | 3b44533324499d355445b502dfff987da8546f1c (diff) | |
download | cortex-m-cde498dab4fbae0bbf093046dc2ae196ce4308d5.tar.gz cortex-m-cde498dab4fbae0bbf093046dc2ae196ce4308d5.tar.zst cortex-m-cde498dab4fbae0bbf093046dc2ae196ce4308d5.zip |
Merge #366
366: itm: derive serde for `LocalTimestampOptions`, impl gated `TryFrom<u8>` r=adamgreig a=tmplt
This PR is an upstream push of more std-features required by `cargo-rtic-scope`. If required, the `TryFrom<u8>` impl can be kept downstream.
Co-authored-by: Viktor Sonesten <v@tmplt.dev>
Diffstat (limited to 'xtask/src')
-rw-r--r-- | xtask/src/lib.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index c3d8356..ddbb88b 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -211,7 +211,7 @@ pub fn check_blobs() { // Check that serde and PartialOrd works with VectActive pub fn check_host_side() { - use cortex_m::peripheral::scb::VectActive; + use cortex_m::peripheral::{itm::LocalTimestampOptions, scb::VectActive}; // check serde { @@ -220,6 +220,12 @@ pub fn check_host_side() { let deser_v: VectActive = serde_json::from_str(&json).expect("Failed to deserialize VectActive"); assert_eq!(deser_v, v); + + let lts = LocalTimestampOptions::EnabledDiv4; + let json = serde_json::to_string(<s).expect("Failed to serialize LocalTimestampOptions"); + let deser_lts: LocalTimestampOptions = + serde_json::from_str(&json).expect("Failed to deserilaize LocalTimestampOptions"); + assert_eq!(deser_lts, lts); } // check PartialOrd @@ -228,4 +234,15 @@ pub fn check_host_side() { let b = VectActive::from(20).unwrap(); assert_eq!(a < b, true); } + + // check TryFrom + { + use core::convert::TryInto; + use std::convert::TryFrom; + + let lts: LocalTimestampOptions = (16 as u8).try_into().unwrap(); + assert_eq!(lts, LocalTimestampOptions::EnabledDiv16); + + assert!(LocalTimestampOptions::try_from(42).is_err()); + } } |