Skip to content

Commit 8d9e01f

Browse files
committed
document the match_byte parsing function.
1 parent dee6833 commit 8d9e01f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/macros/match_byte.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,32 @@ impl Visitor for ExpanderVisitor {
5353
}
5454
}
5555

56+
/// Parses a token tree corresponding to the `match_byte` macro.
57+
///
58+
/// ## Example
59+
///
60+
/// ```rust
61+
/// match_byte! { tokenizer.next_byte_unchecked(),
62+
/// b'a'..b'z' => { ... }
63+
/// b'0'..b'9' => { ... }
64+
/// b'\n' | b'\\' => { ... }
65+
/// foo => { ... }
66+
/// }
67+
///
68+
/// Returns:
69+
/// * The token tree that contains the expression to be matched (in this case
70+
/// `tokenizer.next_byte_unchecked()`.
71+
///
72+
/// * The table with the different cases per byte, each entry in the table
73+
/// contains a non-zero integer representing a different arm of the
74+
/// match expression.
75+
///
76+
/// * The list of cases containing the expansion of the arms of the match
77+
/// expression.
78+
///
79+
/// * An optional identifier to which the wildcard pattern is matched (`foo` in
80+
/// this case).
81+
///
5682
fn parse_match_bytes_macro(tts: Vec<syn::TokenTree>) -> (Vec<syn::TokenTree>, [u8; 256], Vec<Case>, Option<syn::Ident>) {
5783
use syn::TokenTree::Delimited;
5884
use syn::DelimToken::Brace;

0 commit comments

Comments
 (0)