Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# as StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
3
4 use proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#;
5 use proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::{Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream# as TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#};
6 use quoterust-analyzer cargo quote 1.0.47 crate/::quoterust-analyzer cargo quote 1.0.47 quote!;
7 use synrust-analyzer cargo syn 2.0.119 crate/::{
8 foldrust-analyzer cargo syn 2.0.119 gen/fold/::{selfrust-analyzer cargo syn 2.0.119 gen/fold/, Foldrust-analyzer cargo syn 2.0.119 gen/fold/Fold#},
9 parse_quoterust-analyzer cargo syn 2.0.119 parse_quote/,
10 punctuatedrust-analyzer cargo syn 2.0.119 punctuated/::Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#,
11 tokenrust-analyzer cargo syn 2.0.119 token/::Commarust-analyzer cargo syn 2.0.119 token/Comma#,
12 Errorrust-analyzer cargo syn 2.0.119 error/Error#, Exprrust-analyzer cargo syn 2.0.119 expr/Expr#, Itemrust-analyzer cargo syn 2.0.119 item/Item#, Stmtrust-analyzer cargo syn 2.0.119 stmt/Stmt#,
13 };
14
15 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
16 struct Versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version# {
17 majorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#major.: usize,
18 minorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#minor.: usize,
19 }
20
21 impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version# {
22 type Errrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[Version][FromStr]Err# = Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>;
23
24 fn from_strrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[Version][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[Version][FromStr], Selfrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[Version][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
25 let (major_str, minor_str) = s
26 .split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().('.')
27 .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| Selfrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[Version][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/convert/impl#[`Box<dyn Error + 'a>`][`From<String>`]from().("missing `.`".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
28
29 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[Version][FromStr] {
30 majorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#major.: major_str.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
31 minorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#minor.: minor_str.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
32 })
33 }
34 }
35
36 impl Versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version# {
37 fn as_identrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[Version]as_ident().(&self) -> synrust-analyzer cargo syn 2.0.119 crate/::Identrust-analyzer cargo proc-macro2 1.0.107 Ident# {
38 synrust-analyzer cargo syn 2.0.119 crate/::Identrust-analyzer cargo proc-macro2 1.0.107 Ident#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]new().(
39 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("v{}_{}", self.majorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#major., self.minorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#minor.),
40 Spanrust-analyzer cargo proc-macro2 1.0.107 Span#::call_siterust-analyzer cargo proc-macro2 1.0.107 impl#[Span]call_site().(),
41 )
42 }
43 }
44
45 enum VersionReqrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionReq# {
46 Anyrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionReq#Any#(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#>),
47 }
48
49 impl synrust-analyzer cargo syn 2.0.119 crate/::parserust-analyzer cargo syn 2.0.119 parse/::Parserust-analyzer cargo syn 2.0.119 parse/Parse# for VersionReqrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionReq# {
50 fn parserust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionReq][Parse]parse().(input: synrust-analyzer cargo syn 2.0.119 crate/::parserust-analyzer cargo syn 2.0.119 parse/::ParseStreamrust-analyzer cargo syn 2.0.119 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<Selfrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionReq][Parse]> {
51 let versions = Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#::<synrust-analyzer cargo syn 2.0.119 crate/::LitStrrust-analyzer cargo syn 2.0.119 lit/LitStr#, Commarust-analyzer cargo syn 2.0.119 token/Comma#>::parse_terminatedrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]parse_terminated().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
52 .into_iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`][IntoIterator]into_iter().()
53 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.valuerust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]value().().parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(s.spanrust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]span().(), err)))
54 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#>>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
55
56 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionReq][Parse]::Anyrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionReq#Any#(versions))
57 }
58 }
59
60 impl VersionReqrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionReq# {
61 fn matchesrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionReq]matches().(&self, version: &Versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#) -> bool {
62 match self {
63 VersionReqrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionReq#::Anyrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionReq#Any#(versions) => versions.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(version),
64 }
65 }
66 }
67
68 struct VersionFilterrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter# {
69 versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter#version.: Versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#,
70 errorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter#error.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Errorrust-analyzer cargo syn 2.0.119 error/Error#>,
71 }
72
73 impl VersionFilterrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter# {
74 fn is_activerust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]is_active().(&mut self, attrs: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<synrust-analyzer cargo syn 2.0.119 crate/::Attributerust-analyzer cargo syn 2.0.119 attr/Attribute#>) -> bool {
75 let mut matches = true;
76
77 attrs.retainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain().(|attr| {
78 let path = attr.pathrust-analyzer cargo syn 2.0.119 attr/impl#[Attribute]path().();
79
80 if path.is_identrust-analyzer cargo syn 2.0.119 path/impl#[Path]is_ident().("versioned") {
81 match attr.parse_argsrust-analyzer cargo syn 2.0.119 attr/impl#[Attribute]parse_args().::<VersionReqrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionReq#>() {
82 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(req) => matches = req.matchesrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionReq]matches().(&self.versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter#version.),
83 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => match self.errorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter#error..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().() {
84 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(error) => error.combinerust-analyzer cargo syn 2.0.119 error/impl#[Error]combine().(err),
85 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => self.errorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter#error. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(err),
86 },
87 }
88
89 false
90 } else {
91 true
92 }
93 });
94
95 matches
96 }
97
98 fn filter_fieldsrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]filter_fields().(
99 &mut self,
100 fields: Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#<synrust-analyzer cargo syn 2.0.119 crate/::Fieldrust-analyzer cargo syn 2.0.119 data/Field#, Commarust-analyzer cargo syn 2.0.119 token/Comma#>,
101 ) -> Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#<synrust-analyzer cargo syn 2.0.119 crate/::Fieldrust-analyzer cargo syn 2.0.119 data/Field#, Commarust-analyzer cargo syn 2.0.119 token/Comma#> {
102 fields
103 .into_pairsrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]into_pairs().()
104 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|mut pair| self.is_activerust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]is_active().(&mut pair.value_mutrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Pair<T, P>`]value_mut().().attrsrust-analyzer cargo syn 2.0.119 data/Field#attrs.).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(pair))
105 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
106 }
107 }
108
109 impl Foldrust-analyzer cargo syn 2.0.119 gen/fold/Fold# for VersionFilterrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter# {
110 fn fold_fields_namedrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter][Fold]fold_fields_named().(&mut self, mut fields: synrust-analyzer cargo syn 2.0.119 crate/::FieldsNamedrust-analyzer cargo syn 2.0.119 data/FieldsNamed#) -> synrust-analyzer cargo syn 2.0.119 crate/::FieldsNamedrust-analyzer cargo syn 2.0.119 data/FieldsNamed# {
111 fields.namedrust-analyzer cargo syn 2.0.119 data/FieldsNamed#named. = self.filter_fieldsrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]filter_fields().(fields.namedrust-analyzer cargo syn 2.0.119 data/FieldsNamed#named.);
112 fields
113 }
114
115 fn fold_fields_unnamedrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter][Fold]fold_fields_unnamed().(&mut self, mut fields: synrust-analyzer cargo syn 2.0.119 crate/::FieldsUnnamedrust-analyzer cargo syn 2.0.119 data/FieldsUnnamed#) -> synrust-analyzer cargo syn 2.0.119 crate/::FieldsUnnamedrust-analyzer cargo syn 2.0.119 data/FieldsUnnamed# {
116 fields.unnamedrust-analyzer cargo syn 2.0.119 data/FieldsUnnamed#unnamed. = self.filter_fieldsrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]filter_fields().(fields.unnamedrust-analyzer cargo syn 2.0.119 data/FieldsUnnamed#unnamed.);
117 fields
118 }
119
120 fn fold_stmtrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter][Fold]fold_stmt().(&mut self, mut stmt: Stmtrust-analyzer cargo syn 2.0.119 stmt/Stmt#) -> Stmtrust-analyzer cargo syn 2.0.119 stmt/Stmt# {
121 if let Stmtrust-analyzer cargo syn 2.0.119 stmt/Stmt#::Localrust-analyzer cargo syn 2.0.119 stmt/Stmt#Local#(synrust-analyzer cargo syn 2.0.119 crate/::Localrust-analyzer cargo syn 2.0.119 stmt/Local# { ref mut attrsrust-analyzer cargo syn 2.0.119 stmt/Local#attrs., .. })
122 | Stmtrust-analyzer cargo syn 2.0.119 stmt/Stmt#::Macrorust-analyzer cargo syn 2.0.119 stmt/Stmt#Macro#(synrust-analyzer cargo syn 2.0.119 crate/::StmtMacrorust-analyzer cargo syn 2.0.119 stmt/StmtMacro# { ref mut attrsrust-analyzer cargo syn 2.0.119 stmt/StmtMacro#attrs., .. }) = &mut stmt
123 {
124 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_activerust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]is_active().(attrs) {
125 stmt = Stmtrust-analyzer cargo syn 2.0.119 stmt/Stmt#::Itemrust-analyzer cargo syn 2.0.119 stmt/Stmt#Item#(Itemrust-analyzer cargo syn 2.0.119 item/Item#::Verbatimrust-analyzer cargo syn 2.0.119 item/Item#Verbatim#(TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().()));
126 }
127 }
128
129 foldrust-analyzer cargo syn 2.0.119 gen/fold/::fold_stmtrust-analyzer cargo syn 2.0.119 gen/fold/fold_stmt().(self, stmt)
130 }
131
132 fn fold_exprrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter][Fold]fold_expr().(&mut self, mut expr: Exprrust-analyzer cargo syn 2.0.119 expr/Expr#) -> Exprrust-analyzer cargo syn 2.0.119 expr/Expr# {
133 if let Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Arrayrust-analyzer cargo syn 2.0.119 expr/Expr#Array#(synrust-analyzer cargo syn 2.0.119 crate/::ExprArrayrust-analyzer cargo syn 2.0.119 expr/ExprArray# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprArray#attrs., .. })
134 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Assignrust-analyzer cargo syn 2.0.119 expr/Expr#Assign#(synrust-analyzer cargo syn 2.0.119 crate/::ExprAssignrust-analyzer cargo syn 2.0.119 expr/ExprAssign# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprAssign#attrs., .. })
135 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Asyncrust-analyzer cargo syn 2.0.119 expr/Expr#Async#(synrust-analyzer cargo syn 2.0.119 crate/::ExprAsyncrust-analyzer cargo syn 2.0.119 expr/ExprAsync# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprAsync#attrs., .. })
136 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Awaitrust-analyzer cargo syn 2.0.119 expr/Expr#Await#(synrust-analyzer cargo syn 2.0.119 crate/::ExprAwaitrust-analyzer cargo syn 2.0.119 expr/ExprAwait# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprAwait#attrs., .. })
137 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Binaryrust-analyzer cargo syn 2.0.119 expr/Expr#Binary#(synrust-analyzer cargo syn 2.0.119 crate/::ExprBinaryrust-analyzer cargo syn 2.0.119 expr/ExprBinary# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprBinary#attrs., .. })
138 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Blockrust-analyzer cargo syn 2.0.119 expr/Expr#Block#(synrust-analyzer cargo syn 2.0.119 crate/::ExprBlockrust-analyzer cargo syn 2.0.119 expr/ExprBlock# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprBlock#attrs., .. })
139 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Breakrust-analyzer cargo syn 2.0.119 expr/Expr#Break#(synrust-analyzer cargo syn 2.0.119 crate/::ExprBreakrust-analyzer cargo syn 2.0.119 expr/ExprBreak# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprBreak#attrs., .. })
140 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Callrust-analyzer cargo syn 2.0.119 expr/Expr#Call#(synrust-analyzer cargo syn 2.0.119 crate/::ExprCallrust-analyzer cargo syn 2.0.119 expr/ExprCall# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprCall#attrs., .. })
141 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Castrust-analyzer cargo syn 2.0.119 expr/Expr#Cast#(synrust-analyzer cargo syn 2.0.119 crate/::ExprCastrust-analyzer cargo syn 2.0.119 expr/ExprCast# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprCast#attrs., .. })
142 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Closurerust-analyzer cargo syn 2.0.119 expr/Expr#Closure#(synrust-analyzer cargo syn 2.0.119 crate/::ExprClosurerust-analyzer cargo syn 2.0.119 expr/ExprClosure# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprClosure#attrs., .. })
143 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Construst-analyzer cargo syn 2.0.119 expr/Expr#Const#(synrust-analyzer cargo syn 2.0.119 crate/::ExprConstrust-analyzer cargo syn 2.0.119 expr/ExprConst# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprConst#attrs., .. })
144 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Continuerust-analyzer cargo syn 2.0.119 expr/Expr#Continue#(synrust-analyzer cargo syn 2.0.119 crate/::ExprContinuerust-analyzer cargo syn 2.0.119 expr/ExprContinue# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprContinue#attrs., .. })
145 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Fieldrust-analyzer cargo syn 2.0.119 expr/Expr#Field#(synrust-analyzer cargo syn 2.0.119 crate/::ExprFieldrust-analyzer cargo syn 2.0.119 expr/ExprField# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprField#attrs., .. })
146 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::ForLooprust-analyzer cargo syn 2.0.119 expr/Expr#ForLoop#(synrust-analyzer cargo syn 2.0.119 crate/::ExprForLooprust-analyzer cargo syn 2.0.119 expr/ExprForLoop# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprForLoop#attrs., .. })
147 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Grouprust-analyzer cargo syn 2.0.119 expr/Expr#Group#(synrust-analyzer cargo syn 2.0.119 crate/::ExprGrouprust-analyzer cargo syn 2.0.119 expr/ExprGroup# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprGroup#attrs., .. })
148 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Ifrust-analyzer cargo syn 2.0.119 expr/Expr#If#(synrust-analyzer cargo syn 2.0.119 crate/::ExprIfrust-analyzer cargo syn 2.0.119 expr/ExprIf# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprIf#attrs., .. })
149 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Indexrust-analyzer cargo syn 2.0.119 expr/Expr#Index#(synrust-analyzer cargo syn 2.0.119 crate/::ExprIndexrust-analyzer cargo syn 2.0.119 expr/ExprIndex# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprIndex#attrs., .. })
150 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Inferrust-analyzer cargo syn 2.0.119 expr/Expr#Infer#(synrust-analyzer cargo syn 2.0.119 crate/::ExprInferrust-analyzer cargo syn 2.0.119 expr/ExprInfer# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprInfer#attrs., .. })
151 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Letrust-analyzer cargo syn 2.0.119 expr/Expr#Let#(synrust-analyzer cargo syn 2.0.119 crate/::ExprLetrust-analyzer cargo syn 2.0.119 expr/ExprLet# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprLet#attrs., .. })
152 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Litrust-analyzer cargo syn 2.0.119 expr/Expr#Lit#(synrust-analyzer cargo syn 2.0.119 crate/::ExprLitrust-analyzer cargo syn 2.0.119 expr/ExprLit# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprLit#attrs., .. })
153 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Looprust-analyzer cargo syn 2.0.119 expr/Expr#Loop#(synrust-analyzer cargo syn 2.0.119 crate/::ExprLooprust-analyzer cargo syn 2.0.119 expr/ExprLoop# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprLoop#attrs., .. })
154 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Macrorust-analyzer cargo syn 2.0.119 expr/Expr#Macro#(synrust-analyzer cargo syn 2.0.119 crate/::ExprMacrorust-analyzer cargo syn 2.0.119 expr/ExprMacro# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprMacro#attrs., .. })
155 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Matchrust-analyzer cargo syn 2.0.119 expr/Expr#Match#(synrust-analyzer cargo syn 2.0.119 crate/::ExprMatchrust-analyzer cargo syn 2.0.119 expr/ExprMatch# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprMatch#attrs., .. })
156 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::MethodCallrust-analyzer cargo syn 2.0.119 expr/Expr#MethodCall#(synrust-analyzer cargo syn 2.0.119 crate/::ExprMethodCallrust-analyzer cargo syn 2.0.119 expr/ExprMethodCall# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprMethodCall#attrs., .. })
157 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Parenrust-analyzer cargo syn 2.0.119 expr/Expr#Paren#(synrust-analyzer cargo syn 2.0.119 crate/::ExprParenrust-analyzer cargo syn 2.0.119 expr/ExprParen# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprParen#attrs., .. })
158 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Pathrust-analyzer cargo syn 2.0.119 expr/Expr#Path#(synrust-analyzer cargo syn 2.0.119 crate/::ExprPathrust-analyzer cargo syn 2.0.119 expr/ExprPath# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprPath#attrs., .. })
159 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Rangerust-analyzer cargo syn 2.0.119 expr/Expr#Range#(synrust-analyzer cargo syn 2.0.119 crate/::ExprRangerust-analyzer cargo syn 2.0.119 expr/ExprRange# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprRange#attrs., .. })
160 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Referencerust-analyzer cargo syn 2.0.119 expr/Expr#Reference#(synrust-analyzer cargo syn 2.0.119 crate/::ExprReferencerust-analyzer cargo syn 2.0.119 expr/ExprReference# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprReference#attrs., .. })
161 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Repeatrust-analyzer cargo syn 2.0.119 expr/Expr#Repeat#(synrust-analyzer cargo syn 2.0.119 crate/::ExprRepeatrust-analyzer cargo syn 2.0.119 expr/ExprRepeat# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprRepeat#attrs., .. })
162 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Returnrust-analyzer cargo syn 2.0.119 expr/Expr#Return#(synrust-analyzer cargo syn 2.0.119 crate/::ExprReturnrust-analyzer cargo syn 2.0.119 expr/ExprReturn# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprReturn#attrs., .. })
163 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Structrust-analyzer cargo syn 2.0.119 expr/Expr#Struct#(synrust-analyzer cargo syn 2.0.119 crate/::ExprStructrust-analyzer cargo syn 2.0.119 expr/ExprStruct# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprStruct#attrs., .. })
164 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Tryrust-analyzer cargo syn 2.0.119 expr/Expr#Try#(synrust-analyzer cargo syn 2.0.119 crate/::ExprTryrust-analyzer cargo syn 2.0.119 expr/ExprTry# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprTry#attrs., .. })
165 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::TryBlockrust-analyzer cargo syn 2.0.119 expr/Expr#TryBlock#(synrust-analyzer cargo syn 2.0.119 crate/::ExprTryBlockrust-analyzer cargo syn 2.0.119 expr/ExprTryBlock# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprTryBlock#attrs., .. })
166 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Tuplerust-analyzer cargo syn 2.0.119 expr/Expr#Tuple#(synrust-analyzer cargo syn 2.0.119 crate/::ExprTuplerust-analyzer cargo syn 2.0.119 expr/ExprTuple# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprTuple#attrs., .. })
167 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Unaryrust-analyzer cargo syn 2.0.119 expr/Expr#Unary#(synrust-analyzer cargo syn 2.0.119 crate/::ExprUnaryrust-analyzer cargo syn 2.0.119 expr/ExprUnary# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprUnary#attrs., .. })
168 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Unsaferust-analyzer cargo syn 2.0.119 expr/Expr#Unsafe#(synrust-analyzer cargo syn 2.0.119 crate/::ExprUnsaferust-analyzer cargo syn 2.0.119 expr/ExprUnsafe# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprUnsafe#attrs., .. })
169 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Whilerust-analyzer cargo syn 2.0.119 expr/Expr#While#(synrust-analyzer cargo syn 2.0.119 crate/::ExprWhilerust-analyzer cargo syn 2.0.119 expr/ExprWhile# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprWhile#attrs., .. })
170 | Exprrust-analyzer cargo syn 2.0.119 expr/Expr#::Yieldrust-analyzer cargo syn 2.0.119 expr/Expr#Yield#(synrust-analyzer cargo syn 2.0.119 crate/::ExprYieldrust-analyzer cargo syn 2.0.119 expr/ExprYield# { ref mut attrsrust-analyzer cargo syn 2.0.119 expr/ExprYield#attrs., .. }) = &mut expr
171 {
172 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_activerust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]is_active().(attrs) {
173 expr = parse_quoterust-analyzer cargo syn 2.0.119 parse_quote/parse_quote!!({});
174 }
175 }
176
177 foldrust-analyzer cargo syn 2.0.119 gen/fold/::fold_exprrust-analyzer cargo syn 2.0.119 gen/fold/fold_expr().(self, expr)
178 }
179
180 fn fold_expr_structrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter][Fold]fold_expr_struct().(&mut self, mut expr: synrust-analyzer cargo syn 2.0.119 crate/::ExprStructrust-analyzer cargo syn 2.0.119 expr/ExprStruct#) -> synrust-analyzer cargo syn 2.0.119 crate/::ExprStructrust-analyzer cargo syn 2.0.119 expr/ExprStruct# {
181 expr.fieldsrust-analyzer cargo syn 2.0.119 expr/ExprStruct#fields. = expr
182 .fieldsrust-analyzer cargo syn 2.0.119 expr/ExprStruct#fields.
183 .into_pairsrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]into_pairs().()
184 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|mut pair| self.is_activerust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]is_active().(&mut pair.value_mutrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Pair<T, P>`]value_mut().().attrsrust-analyzer cargo syn 2.0.119 expr/FieldValue#attrs.).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(pair))
185 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
186
187 foldrust-analyzer cargo syn 2.0.119 gen/fold/::fold_expr_structrust-analyzer cargo syn 2.0.119 gen/fold/fold_expr_struct().(self, expr)
188 }
189
190 fn fold_expr_matchrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter][Fold]fold_expr_match().(&mut self, mut expr: synrust-analyzer cargo syn 2.0.119 crate/::ExprMatchrust-analyzer cargo syn 2.0.119 expr/ExprMatch#) -> synrust-analyzer cargo syn 2.0.119 crate/::ExprMatchrust-analyzer cargo syn 2.0.119 expr/ExprMatch# {
191 expr.armsrust-analyzer cargo syn 2.0.119 expr/ExprMatch#arms..retain_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]retain_mut().(|arm| self.is_activerust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]is_active().(&mut arm.attrsrust-analyzer cargo syn 2.0.119 expr/Arm#attrs.));
192
193 foldrust-analyzer cargo syn 2.0.119 gen/fold/::fold_expr_matchrust-analyzer cargo syn 2.0.119 gen/fold/fold_expr_match().(self, expr)
194 }
195
196 fn fold_itemrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter][Fold]fold_item().(&mut self, mut item: Itemrust-analyzer cargo syn 2.0.119 item/Item#) -> Itemrust-analyzer cargo syn 2.0.119 item/Item# {
197 if let Itemrust-analyzer cargo syn 2.0.119 item/Item#::Construst-analyzer cargo syn 2.0.119 item/Item#Const#(synrust-analyzer cargo syn 2.0.119 crate/::ItemConstrust-analyzer cargo syn 2.0.119 item/ItemConst# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemConst#attrs., .. })
198 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Enumrust-analyzer cargo syn 2.0.119 item/Item#Enum#(synrust-analyzer cargo syn 2.0.119 crate/::ItemEnumrust-analyzer cargo syn 2.0.119 item/ItemEnum# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemEnum#attrs., .. })
199 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::ExternCraterust-analyzer cargo syn 2.0.119 item/Item#ExternCrate#(synrust-analyzer cargo syn 2.0.119 crate/::ItemExternCraterust-analyzer cargo syn 2.0.119 item/ItemExternCrate# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemExternCrate#attrs., .. })
200 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Fnrust-analyzer cargo syn 2.0.119 item/Item#Fn#(synrust-analyzer cargo syn 2.0.119 crate/::ItemFnrust-analyzer cargo syn 2.0.119 item/ItemFn# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemFn#attrs., .. })
201 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::ForeignModrust-analyzer cargo syn 2.0.119 item/Item#ForeignMod#(synrust-analyzer cargo syn 2.0.119 crate/::ItemForeignModrust-analyzer cargo syn 2.0.119 item/ItemForeignMod# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemForeignMod#attrs., .. })
202 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Implrust-analyzer cargo syn 2.0.119 item/Item#Impl#(synrust-analyzer cargo syn 2.0.119 crate/::ItemImplrust-analyzer cargo syn 2.0.119 item/ItemImpl# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemImpl#attrs., .. })
203 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Macrorust-analyzer cargo syn 2.0.119 item/Item#Macro#(synrust-analyzer cargo syn 2.0.119 crate/::ItemMacrorust-analyzer cargo syn 2.0.119 item/ItemMacro# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemMacro#attrs., .. })
204 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Modrust-analyzer cargo syn 2.0.119 item/Item#Mod#(synrust-analyzer cargo syn 2.0.119 crate/::ItemModrust-analyzer cargo syn 2.0.119 item/ItemMod# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemMod#attrs., .. })
205 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Staticrust-analyzer cargo syn 2.0.119 item/Item#Static#(synrust-analyzer cargo syn 2.0.119 crate/::ItemStaticrust-analyzer cargo syn 2.0.119 item/ItemStatic# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemStatic#attrs., .. })
206 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Structrust-analyzer cargo syn 2.0.119 item/Item#Struct#(synrust-analyzer cargo syn 2.0.119 crate/::ItemStructrust-analyzer cargo syn 2.0.119 item/ItemStruct# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemStruct#attrs., .. })
207 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Traitrust-analyzer cargo syn 2.0.119 item/Item#Trait#(synrust-analyzer cargo syn 2.0.119 crate/::ItemTraitrust-analyzer cargo syn 2.0.119 item/ItemTrait# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemTrait#attrs., .. })
208 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::TraitAliasrust-analyzer cargo syn 2.0.119 item/Item#TraitAlias#(synrust-analyzer cargo syn 2.0.119 crate/::ItemTraitAliasrust-analyzer cargo syn 2.0.119 item/ItemTraitAlias# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemTraitAlias#attrs., .. })
209 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Typerust-analyzer cargo syn 2.0.119 item/Item#Type#(synrust-analyzer cargo syn 2.0.119 crate/::ItemTyperust-analyzer cargo syn 2.0.119 item/ItemType# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemType#attrs., .. })
210 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Unionrust-analyzer cargo syn 2.0.119 item/Item#Union#(synrust-analyzer cargo syn 2.0.119 crate/::ItemUnionrust-analyzer cargo syn 2.0.119 item/ItemUnion# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemUnion#attrs., .. })
211 | Itemrust-analyzer cargo syn 2.0.119 item/Item#::Userust-analyzer cargo syn 2.0.119 item/Item#Use#(synrust-analyzer cargo syn 2.0.119 crate/::ItemUserust-analyzer cargo syn 2.0.119 item/ItemUse# { ref mut attrsrust-analyzer cargo syn 2.0.119 item/ItemUse#attrs., .. }) = &mut item
212 {
213 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.is_activerust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]is_active().(attrs) {
214 item = Itemrust-analyzer cargo syn 2.0.119 item/Item#::Verbatimrust-analyzer cargo syn 2.0.119 item/Item#Verbatim#(TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().());
215 }
216 }
217
218 foldrust-analyzer cargo syn 2.0.119 gen/fold/::fold_itemrust-analyzer cargo syn 2.0.119 gen/fold/fold_item().(self, item)
219 }
220
221 fn fold_item_enumrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter][Fold]fold_item_enum().(&mut self, mut item: synrust-analyzer cargo syn 2.0.119 crate/::ItemEnumrust-analyzer cargo syn 2.0.119 item/ItemEnum#) -> synrust-analyzer cargo syn 2.0.119 crate/::ItemEnumrust-analyzer cargo syn 2.0.119 item/ItemEnum# {
222 item.variantsrust-analyzer cargo syn 2.0.119 item/ItemEnum#variants. = item
223 .variantsrust-analyzer cargo syn 2.0.119 item/ItemEnum#variants.
224 .into_iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`][IntoIterator]into_iter().()
225 .filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|mut variant| self.is_activerust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter]is_active().(&mut variant.attrsrust-analyzer cargo syn 2.0.119 data/Variant#attrs.).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(variant))
226 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
227
228 foldrust-analyzer cargo syn 2.0.119 gen/fold/::fold_item_enumrust-analyzer cargo syn 2.0.119 gen/fold/fold_item_enum().(self, item)
229 }
230 }
231
232 fn helperrust-analyzer cargo cyclonedx-bom-macros 0.1.0 helper().(input: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#, annotated_item: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#> {
233 // This parses the module being annotated by the `#[versioned(..)]` attribute.
234 let module = synrust-analyzer cargo syn 2.0.119 crate/::parserust-analyzer cargo syn 2.0.119 parse().::<synrust-analyzer cargo syn 2.0.119 crate/::ItemModrust-analyzer cargo syn 2.0.119 item/ItemMod#>(annotated_item)
235 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(err.spanrust-analyzer cargo syn 2.0.119 error/impl#[Error]span().(), formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("cannot parse module: {err}")))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
236
237 // This parses the versions passed to the attribute, e.g. the `"1.3"`
238 // and `"1.4"`in `#[versioned("1.3", "1.4")]
239 let versions =
240 synrust-analyzer cargo syn 2.0.119 crate/::parserust-analyzer cargo syn 2.0.119 parse/::Parserrust-analyzer cargo syn 2.0.119 parse/Parser#::parserust-analyzer cargo syn 2.0.119 parse/Parser#parse().(Punctuatedrust-analyzer cargo syn 2.0.119 punctuated/Punctuated#::<synrust-analyzer cargo syn 2.0.119 crate/::LitStrrust-analyzer cargo syn 2.0.119 lit/LitStr#, Commarust-analyzer cargo syn 2.0.119 token/Comma#>::parse_terminatedrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`]parse_terminated()., input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
241 .into_iterrust-analyzer cargo syn 2.0.119 punctuated/impl#[`Punctuated<T, P>`][IntoIterator]into_iter().()
242 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|s| s.valuerust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]value().().parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(s.spanrust-analyzer cargo syn 2.0.119 lit/impl#[LitStr]span().(), err)))
243 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<synrust-analyzer cargo syn 2.0.119 crate/::Resultrust-analyzer cargo syn 2.0.119 error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 Version#>>>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
244
245 let content = module
246 .contentrust-analyzer cargo syn 2.0.119 item/ItemMod#content.
247 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
248 .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(module.identrust-analyzer cargo syn 2.0.119 item/ItemMod#ident..spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(), "found module without content"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
249
250 let mut tokens = TokenStream2rust-analyzer cargo proc-macro2 1.0.107 TokenStream#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream]new().();
251
252 for version in versions {
253 let mod_vis = &module.visrust-analyzer cargo syn 2.0.119 item/ItemMod#vis.;
254 let mod_ident = version.as_identrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[Version]as_ident().();
255
256 let items = content.1.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().();
257
258 let mut folded_items = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
259
260 let mut filter = VersionFilterrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter# {
261 versionrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter#version.,
262 errorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter#error.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
263 };
264
265 for item in items {
266 folded_items.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(filter.fold_itemrust-analyzer cargo cyclonedx-bom-macros 0.1.0 impl#[VersionFilter][Fold]fold_item().(item));
267 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(error) = filter.errorrust-analyzer cargo cyclonedx-bom-macros 0.1.0 VersionFilter#error. {
268 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error);
269 }
270 }
271
272 tokens.extendrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`Extend<TokenTree>`]extend().(quoterust-analyzer cargo quote 1.0.47 quote!! {
273 #mod_vis mod #mod_ident {
274 #(#folded_items)*
275 }
276 })
277 }
278
279 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(tokens)
280 }
281
282 /// A `cfg`-like attribute macro to generate versioned modules.
283 ///
284 /// This macro allows to duplicate a module by providing version numbers to the
285 /// macro itself. For example:
286 /// ```rust
287 /// use cyclonedx_bom_macros::versioned;
288 ///
289 /// #[versioned("1.0", "2.0")]
290 /// mod base {
291 /// pub(super) struct Foo;
292 /// }
293 /// ```
294 /// Will generate two modules: `v1_0` and `v2_0`, where each one of them
295 /// contains the definition of `Foo`:
296 /// ```rust
297 /// mod v1_0 {
298 /// pub(super) struct Foo;
299 /// }
300 ///
301 /// mod v2_0 {
302 /// pub(super) struct Foo;
303 /// }
304 /// ```
305 /// Additionally the macro can be used to gate definitions and expressions
306 /// behind a specific version, very much like the `cfg` attribute. Based on the
307 /// previous example:
308 /// ```rust
309 /// use cyclonedx_bom_macros::versioned;
310 ///
311 /// #[versioned("1.0", "2.0")]
312 /// mod base {
313 /// pub(super) struct Foo;
314 ///
315 /// #[versioned("2.0")]
316 /// pub(super) struct Bar;
317 /// }
318 /// ```
319 /// The following code will be generated:
320 /// ```rust
321 /// mod v1_0 {
322 /// pub(super) struct Foo;
323 /// }
324 ///
325 /// mod v2_0 {
326 /// pub(super) struct Foo;
327 /// pub(super) struct Bar;
328 /// }
329 /// ```
330 /// Note that `Bar` only exists inside the `v2_0` module. Note that the
331 /// `versioned` attribute annotating the module defines the versions that will be
332 /// used to generate the modules and the attribute annotating the `Bar` definition
333 /// states that this definition will only appear on the `2.0` module.
334 ///
335 /// Check the test folder for more usage examples.
336 #[proc_macro_attribute]
337 pub fn versionedrust-analyzer cargo cyclonedx-bom-macros 0.1.0 versioned:(input: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#, annotated_item: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# {
338 match helperrust-analyzer cargo cyclonedx-bom-macros 0.1.0 helper().(input, annotated_item) {
339 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(tokens) => tokens,
340 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(
341 err.spanrust-analyzer cargo syn 2.0.119 error/impl#[Error]span().(),
342 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{err} while using the `#[versioned]` macro"),
343 )
344 .into_compile_errorrust-analyzer cargo syn 2.0.119 error/impl#[Error]into_compile_error().(),
345 }
346 .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
347 }