1 | use syn::Attribute; |
2 | |
3 | /// Doc-comment, implementing `quote::ToTokens`. |
4 | /// |
5 | /// # Examples |
6 | /// |
7 | /// Will expand to something like the following (depending on inner value): |
8 | /// |
9 | /// ```rust,ignore |
10 | /// # #[macro_use ] |
11 | /// # extern crate quote; |
12 | /// # extern crate syn; |
13 | /// # extern crate derive_builder_core; |
14 | /// # use derive_builder_core::doc_comment_from; |
15 | /// # fn main() { |
16 | /// # let doc_comment = doc_comment_from("foo" .to_string()); |
17 | /// # |
18 | /// # assert_eq!(quote!(#doc_comment).to_string(), quote!( |
19 | /// #[doc = "foo" ] |
20 | /// # ).to_string()); |
21 | /// # } |
22 | /// ``` |
23 | pub fn doc_comment_from(s: String) -> Attribute { |
24 | parse_quote!(#[doc=#s]) |
25 | } |
26 | |