1
0
mirror of https://github.com/danog/strum.git synced 2024-11-30 04:28:59 +01:00

Handle rustoc comments in #[derive(FromRepr)] (#276)

This commit is contained in:
Samuel Moelius 2023-07-03 16:45:32 -04:00 committed by GitHub
parent 0a0def76bd
commit 93ea44dd12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -16,7 +16,15 @@ pub fn from_repr_inner(ast: &DeriveInput) -> syn::Result<TokenStream> {
for attr in attrs { for attr in attrs {
let path = attr.path(); let path = attr.path();
let mut ts = attr.meta.require_list()?.to_token_stream().into_iter(); let mut ts = if let Ok(ts) = attr
.meta
.require_list()
.map(|metas| metas.to_token_stream().into_iter())
{
ts
} else {
continue;
};
// Discard the path // Discard the path
let _ = ts.next(); let _ = ts.next();
let tokens: TokenStream = ts.collect(); let tokens: TokenStream = ts.collect();

View File

@ -1,6 +1,7 @@
use strum::FromRepr; use strum::FromRepr;
#[derive(Debug, FromRepr, PartialEq)] #[derive(Debug, FromRepr, PartialEq)]
/// Day of the week
#[repr(u8)] #[repr(u8)]
enum Week { enum Week {
Sunday, Sunday,