diff options
author | 2019-02-26 23:25:16 +0100 | |
---|---|---|
committer | 2019-02-26 23:25:16 +0100 | |
commit | 8eccef7d9cda8a60594b86d31b656a3680d1ca16 (patch) | |
tree | ee9aa60d3c109b4583299cf6a71277507a4be241 /macros/src/syntax.rs | |
parent | 2fd6ae69d1c79635896b643b1094b3805d1ec6c2 (diff) | |
download | rtic-8eccef7d9cda8a60594b86d31b656a3680d1ca16.tar.gz rtic-8eccef7d9cda8a60594b86d31b656a3680d1ca16.tar.zst rtic-8eccef7d9cda8a60594b86d31b656a3680d1ca16.zip |
refactor: make `binds` harder to misuse
Diffstat (limited to 'macros/src/syntax.rs')
-rw-r--r-- | macros/src/syntax.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/macros/src/syntax.rs b/macros/src/syntax.rs index 23981d98..7f87f633 100644 --- a/macros/src/syntax.rs +++ b/macros/src/syntax.rs @@ -731,13 +731,20 @@ pub struct Exception { } pub struct ExceptionArgs { - pub binds: Option<Ident>, + binds: Option<Ident>, pub priority: u8, pub resources: Idents, pub schedule: Idents, pub spawn: Idents, } +impl ExceptionArgs { + /// Returns the name of the exception / interrupt this handler binds to + pub fn binds<'a>(&'a self, handler: &'a Ident) -> &'a Ident { + self.binds.as_ref().unwrap_or(handler) + } +} + impl Parse for ExceptionArgs { fn parse(input: ParseStream<'_>) -> parse::Result<Self> { parse_args(input, /* binds */ true, /* capacity */ false).map( |