Debian Codegraph @

tests/mac_attrs.rs

raw symbols SCIP
1 /*
2 Copyright ⓒ 2016 macro-attr contributors.
3
4 Licensed under the MIT license (see LICENSE or <http://opensource.org
5 /licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of
6 <http://www.apache.org/licenses/LICENSE-2.0>), at your option. All
7 files in the project carrying such notice may not be copied, modified,
8 or distributed except according to those terms.
9 */
10 #[macro_use] extern crate macro_attrrust-analyzer cargo macro-attr 0.2.0 macro_attr/;
11
12 macro_rules! Namerust-analyzer cargo macro-attr 0.2.0 Name! {
13 (
14 ()
15 struct $name:ident $($_tail:tt)*
16 ) => {
17 impl $name {
18 pub fn name() -> &'static str {
19 stringify!($name)
20 }
21 }
22 };
23 }
24
25 macro_rules! remove_bodyrust-analyzer cargo macro-attr 0.2.0 remove_body! {
26 (
27 (),
28 then $cb:tt,
29 $(#[$($attrs:tt)*])*
30 struct $name:ident $($_tail:tt)*
31 ) => {
32 macro_attr_callback! {
33 $cb,
34 $(#[$($attrs)*])*
35 struct $name;
36 }
37 };
38 }
39
40 macro_rules! use_secret_aliasrust-analyzer cargo macro-attr 0.2.0 use_secret_alias! {
41 (
42 ($name:ident),
43 then $cb:tt,
44 $(#[$($attrs:tt)*])*
45 struct $_old_name:ident $($tail:tt)*
46 ) => {
47 macro_attr_callback! {
48 $cb,
49 $(#[$($attrs)*])*
50 struct $name $($tail)*
51 }
52 };
53 }
54
55 macro_attrrust-analyzer cargo macro-attr 0.2.0 macro_attr!! {
56 #[derive(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Namerust-analyzer cargo macro-attr 0.2.0 Name!!)]
57 #[remove_bodyrust-analyzer cargo macro-attr 0.2.0 remove_body!!]
58 #[use_secret_aliasrust-analyzer cargo macro-attr 0.2.0 use_secret_alias!!(Alucardrust-analyzer cargo macro-attr 0.2.0 Alucard#)]
59 struct Dracula {
60 pub vulnerabilities: Vec<Vulnerability>,
61 }
62 }
63
64 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
65 fn test_mac_attrsrust-analyzer cargo macro-attr 0.2.0 test_mac_attrs().() {
66 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", Alucardrust-analyzer cargo macro-attr 0.2.0 Alucard#), "Alucard");
67 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Alucardrust-analyzer cargo macro-attr 0.2.0 Alucard#::namerust-analyzer cargo macro-attr 0.2.0 impl#[Alucard]name().(), "Alucard");
68 }