caret: work correctly when there are no defined variants.

This commit is contained in:
Nick Mathewson 2023-02-27 14:12:11 -05:00
parent d69ed3bc62
commit 841905948f
1 changed files with 4 additions and 2 deletions

View File

@ -107,8 +107,10 @@ macro_rules! caret_int {
}
/// Return true if this value is one that we recognize.
$v fn is_recognized(self) -> bool {
matches!(self,
$( $name::$id )|*)
match self {
$( $name::$id => true, )*
_ => false
}
}
/// Try to convert this value from one of the recognized names.
$v fn from_name(name: &str) -> Option<Self> {