Netdoc: allow doc comments and visibility modifier in decl_keyword!

This commit is contained in:
Nick Mathewson 2020-05-09 13:31:29 -04:00
parent 73752fb647
commit 5d3f13e6e7
2 changed files with 6 additions and 4 deletions

View File

@ -20,10 +20,12 @@
/// assert_eq!(Location::from_str("stfff"), Location::UNRECOGNIZED);
/// ```
macro_rules! decl_keyword {
{ $name:ident { $( $($s:literal)|+ => $i:ident),* $(,)? } } => {
{ $(#[$meta:meta])* $v:vis
$name:ident { $( $($s:literal)|+ => $i:ident),* $(,)? } } => {
#[derive(Copy,Clone,Eq,PartialEq,Debug,std::hash::Hash)]
#[allow(non_camel_case_types)]
enum $name {
$(#[$meta])*
$v enum $name {
$( $i , )*
UNRECOGNIZED
}

View File

@ -112,9 +112,9 @@ pub enum RelayPlatform {
Other(String),
}
// RouterKW is an instance of Keyword, used to denote the different
// Items that are recognized as appearing in a router descriptor.
decl_keyword! {
/// RouterKW is an instance of Keyword, used to denote the different
/// Items that are recognized as appearing in a router descriptor.
RouterKW {
"accept" | "reject" => POLICY,
"bandwidth" => BANDWIDTH,