Skip to content

Commit

Permalink
docs(traits): add docs to each of the trait mods
Browse files Browse the repository at this point in the history
closes #2
  • Loading branch information
onkoe committed Jul 10, 2024
1 parent 329031d commit 179e59d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions macros/src/traits/display.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! # Display
//!
//! Implements `Display` for the user's error type.

use proc_macro2::{Span as Span2, TokenStream as TokenStream2};
use quote::quote;
use syn::{punctuated::Punctuated, token::Comma, Ident, Meta, Variant};
Expand Down
8 changes: 6 additions & 2 deletions macros/src/traits/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! # Error
//!
//! Implements the `Error` trait for the user's error type.

use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use syn::{punctuated::Punctuated, token::Comma, Ident, Variant};
Expand Down Expand Up @@ -31,7 +35,7 @@ pub fn source(
enum_name: &Ident,
) -> syn::Result<TokenStream2> {
// store each variant's match arm, if it's even there!
let list = variants.iter().map(|v| {
let match_arms = variants.iter().map(|v| {
let is_from = variant_froms.contains(&v);

match is_from {
Expand Down Expand Up @@ -70,7 +74,7 @@ pub fn source(
Ok(quote! {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match *self {
#(#list),*
#(#match_arms),*
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion macros/src/traits/from.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! # From
//!
//! Implements the `From` trait for the user's type.
//! Implements the `From` trait for the user's error type.

use proc_macro2::{Span as Span2, TokenStream as TokenStream2};
use quote::{quote, quote_spanned};
Expand Down

0 comments on commit 179e59d

Please sign in to comment.