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 21, 2021
1 parent 718fbb6 commit 0de17d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/is_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
Fields::Unit => quote! {},
};
let func = quote! {
#[doc = "Returns `true` if this value is of type `"]
#[doc = stringify!(#variant_ident)]
#[doc = "`. Returns false otherwise"]
pub fn #fn_name(&self) -> bool {
match self {
#enum_name ::#variant_ident #data_pattern => true,
Expand Down
3 changes: 3 additions & 0 deletions src/unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
};
let func = quote! {
#track_caller
#[doc = "Unwraps this value to the `"]
#[doc = stringify!(#variant_ident)]
#[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 0de17d7

Please sign in to comment.