Skip to content

Commit dcbb4a2

Browse files
authored
Merge pull request #111 from parker-research/macro-docs
Add docstrings to `unwrap_node` and `unwrap_locate` macros
2 parents de6136f + 46f256f commit dcbb4a2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

sv-parser/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,21 @@ pub fn parse_lib_pp(
335335
}
336336
}
337337

338+
/// Extracts the first matching variant from an iterator of `RefNode` values.
339+
///
340+
/// This macro takes an iterator (`$n`) and a list of `RefNode` variant types (`$ty`),
341+
/// returning the first occurrence of any specified variant as `Some(RefNode::<$ty>)`.
342+
/// If no matching variant is found, it returns `None`.
343+
///
344+
/// # Arguments
345+
///
346+
/// - `$n`: An iterator over `RefNode` values.
347+
/// - `$ty`: One or more `RefNode` variant names to search for.
348+
///
349+
/// # Returns
350+
///
351+
/// - `Some(RefNode::<$ty>)` if a matching variant is found.
352+
/// - `None` if no matching variant is found.
338353
#[macro_export]
339354
macro_rules! unwrap_node {
340355
($n:expr, $( $ty:tt ),+) => {{
@@ -351,6 +366,20 @@ macro_rules! unwrap_node {
351366
}};
352367
}
353368

369+
/// Extracts the first `Locate` variant from an iterator of `RefNode`.
370+
///
371+
/// This macro takes an expression that evaluates to an iterable collection
372+
/// of `RefNode` elements and returns the first `Locate` variant found,
373+
/// if any. If no `Locate` variant is found, it returns `None`.
374+
///
375+
/// # Arguments
376+
///
377+
/// * `$n:expr` - An expression yielding an iterator over `RefNode` values.
378+
///
379+
/// # Returns
380+
///
381+
/// * `Option<Locate>` - The first `Locate` variant found in the iterator, or `None` if none exist.
382+
///
354383
#[macro_export]
355384
macro_rules! unwrap_locate {
356385
($n:expr) => {{

0 commit comments

Comments
 (0)