From 8eccef7d9cda8a60594b86d31b656a3680d1ca16 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Tue, 26 Feb 2019 23:25:16 +0100 Subject: refactor: make `binds` harder to misuse --- macros/src/syntax.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'macros/src/syntax.rs') diff --git a/macros/src/syntax.rs b/macros/src/syntax.rs index 23981d9..7f87f63 100644 --- a/macros/src/syntax.rs +++ b/macros/src/syntax.rs @@ -731,13 +731,20 @@ pub struct Exception { } pub struct ExceptionArgs { - pub binds: Option, + binds: Option, 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 { parse_args(input, /* binds */ true, /* capacity */ false).map( -- cgit v1.2.3