Skip to content

Commit

Permalink
Add doc comments for Unwrap, IsVariant
Browse files Browse the repository at this point in the history
Prevents a linting issue from `missing_docs` on the derived functions
  • Loading branch information
Technohacker committed Dec 23, 2021
1 parent 718fbb6 commit 83f091a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/is_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
Fields::Unnamed(_) => quote! { (..) },
Fields::Unit => quote! {},
};
let variant_name = stringify!(variant_ident);
let func = quote! {
#[doc = "Returns `true` if this value is of type `"]
#[doc = #variant_name]
#[doc = "`. Returns `false` otherwise"]
pub fn #fn_name(&self) -> bool {
match self {
#enum_name ::#variant_ident #data_pattern => true,
Expand Down
4 changes: 4 additions & 0 deletions src/unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
} else {
quote! {}
};
let variant_name = stringify!(variant_ident);
let func = quote! {
#track_caller
#[doc = "Unwraps this value to the `"]
#[doc = #variant_name]
#[doc = "` variant\n\nPanics if this value is of any other type"]
pub fn #fn_name(self) -> #ret_type {
match self {
#enum_name ::#variant_ident #data_pattern => #ret_value,
Expand Down

0 comments on commit 83f091a

Please sign in to comment.