Skip to content

Commit ab0336b

Browse files
committed
chore: Move get docs to trait
1 parent 9dd8bc3 commit ab0336b

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

crates/macros/src/helpers.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use crate::class::{parse_attribute, ParsedAttribute};
22
use syn::Attribute;
33

4+
pub type Docs = Vec<String>;
5+
46
/// Takes a list of attributes and returns a list of doc comments retrieved from
57
/// the attributes.
68
pub fn get_docs(attrs: &[Attribute]) -> Vec<String> {
@@ -14,3 +16,13 @@ pub fn get_docs(attrs: &[Attribute]) -> Vec<String> {
1416

1517
docs
1618
}
19+
20+
pub trait GetDocs {
21+
fn get_docs(&self) -> Docs;
22+
}
23+
24+
impl GetDocs for &[Attribute] {
25+
fn get_docs(&self) -> Docs {
26+
get_docs(self)
27+
}
28+
}

crates/macros/src/method.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ use darling::FromMeta;
66
use proc_macro2::TokenStream;
77
use syn::{FnArg, Ident, ImplItemFn, ItemFn, TraitItemFn};
88

9-
// pub enum FunctionLikeType {
10-
// Interface(TraitItemFn),
11-
// Impl(ImplItemFn),
12-
// Function(ItemFn),
13-
// }
14-
159
pub trait FunctionLike: GetDocs {
1610
fn name(&self) -> String;
1711

0 commit comments

Comments
 (0)