aboutsummaryrefslogtreecommitdiff
path: root/examples/destructure.rs
diff options
context:
space:
mode:
authorGravatar Per Lindgren <per.lindgren@ltu.se> 2023-01-07 17:59:39 +0100
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2023-03-01 00:33:24 +0100
commit9a4f97ca5ebf19e6612115db5c763d0d61dd28a1 (patch)
tree1f37d247f715ad3d5215aa7de3aa6d4eb94a7027 /examples/destructure.rs
parent5606ba3cf38c80be5d3e9c88ad4da9982b114851 (diff)
downloadrtic-9a4f97ca5ebf19e6612115db5c763d0d61dd28a1.tar.gz
rtic-9a4f97ca5ebf19e6612115db5c763d0d61dd28a1.tar.zst
rtic-9a4f97ca5ebf19e6612115db5c763d0d61dd28a1.zip
more examples
Diffstat (limited to 'examples/destructure.rs')
-rw-r--r--examples/destructure.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/destructure.rs b/examples/destructure.rs
index 6019c225..89336bfd 100644
--- a/examples/destructure.rs
+++ b/examples/destructure.rs
@@ -4,6 +4,7 @@
#![deny(warnings)]
#![no_main]
#![no_std]
+#![feature(type_alias_impl_trait)]
use panic_semihosting as _;
@@ -22,11 +23,11 @@ mod app {
struct Local {}
#[init]
- fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
+ fn init(_: init::Context) -> (Shared, Local) {
foo::spawn().unwrap();
bar::spawn().unwrap();
- (Shared { a: 0, b: 0, c: 0 }, Local {}, init::Monotonics())
+ (Shared { a: 0, b: 1, c: 2 }, Local {})
}
#[idle]
@@ -37,7 +38,7 @@ mod app {
// Direct destructure
#[task(shared = [&a, &b, &c])]
- fn foo(cx: foo::Context) {
+ async fn foo(cx: foo::Context) {
let a = cx.shared.a;
let b = cx.shared.b;
let c = cx.shared.c;
@@ -47,8 +48,8 @@ mod app {
// De-structure-ing syntax
#[task(shared = [&a, &b, &c])]
- fn bar(cx: bar::Context) {
- let bar::SharedResources { a, b, c } = cx.shared;
+ async fn bar(cx: bar::Context) {
+ let bar::SharedResources { a, b, c, .. } = cx.shared;
hprintln!("bar: a = {}, b = {}, c = {}", a, b, c).unwrap();
}