Add unwrap_locate
This commit is contained in:
parent
5303d8e763
commit
6abcdae565
@ -2,6 +2,8 @@
|
||||
|
||||
## [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
|
||||
|
||||
* [Added] get_origin to SyntaxTree
|
||||
|
@ -155,3 +155,19 @@ macro_rules! unwrap_node {
|
||||
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()
|
||||
}};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user