Add unwrap_locate

This commit is contained in:
dalance 2019-10-29 15:36:11 +09:00
parent 5303d8e763
commit 6abcdae565
2 changed files with 18 additions and 0 deletions

View File

@ -2,6 +2,8 @@
## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.2.1...Unreleased) - ReleaseDate ## [Unreleased](https://github.com/dalance/sv-parser/compare/v0.2.1...Unreleased) - ReleaseDate
* [Added] unwrap_locate macro
## [v0.2.1](https://github.com/dalance/sv-parser/compare/v0.2.0...v0.2.1) - 2019-10-28 ## [v0.2.1](https://github.com/dalance/sv-parser/compare/v0.2.0...v0.2.1) - 2019-10-28
* [Added] get_origin to SyntaxTree * [Added] get_origin to SyntaxTree

View File

@ -155,3 +155,19 @@ macro_rules! unwrap_node {
unwrap() unwrap()
}}; }};
} }
#[macro_export]
macro_rules! unwrap_locate {
($n:expr) => {{
let unwrap = || {
for x in $n {
match x {
sv_parser::RefNode::Locate(x) => return Some(x),
_ => (),
}
}
None
};
unwrap()
}};
}