| 1 | 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#; |
| 2 | |
| 3 | use proc_macro2rust-analyzer cargo proc-macro2 1.0.95 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.95 TokenStream#; |
| 4 | use synrust-analyzer cargo syn 2.0.104 crate/::Tokenrust-analyzer cargo syn 2.0.104 token/Token!; |
| 5 | use synrust-analyzer cargo syn 2.0.104 crate/::parserust-analyzer cargo syn 2.0.104 parse/::{Parserust-analyzer cargo syn 2.0.104 parse/Parse#, ParseStreamrust-analyzer cargo syn 2.0.104 parse/ParseStream#}; |
| 6 | |
| 7 | use craterust-analyzer cargo bitfields-impl 1.0.0 crate/::create_syn_errorrust-analyzer cargo bitfields-impl 1.0.0 create_syn_error().; |
| 8 | |
| 9 | /// Represents a field in a bitfield struct. |
| 10 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 11 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) struct BitfieldFieldrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField# { |
| 12 | /// The name of the field. |
| 13 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) namerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#name.: synrust-analyzer cargo syn 2.0.104 crate/::Identrust-analyzer cargo proc-macro2 1.0.95 Ident#, |
| 14 | /// The type of the field. |
| 15 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) tyrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#ty.: synrust-analyzer cargo syn 2.0.104 crate/::Typerust-analyzer cargo syn 2.0.104 ty/Type#, |
| 16 | /// The visibility of the field. |
| 17 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) visrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#vis.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.104 crate/::Visibilityrust-analyzer cargo syn 2.0.104 restriction/Visibility#>, |
| 18 | /// The number of bits the field occupies. |
| 19 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#bits.: u8, |
| 20 | /// The offset of the field. |
| 21 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) offsetrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#offset.: u8, |
| 22 | /// The default value of the field as a token stream. This allows us to |
| 23 | /// insert the default value in any token stream without complicated |
| 24 | /// conversions or parsing. |
| 25 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) default_value_tokensrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#default_value_tokens.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TokenStreamrust-analyzer cargo proc-macro2 1.0.95 TokenStream#>, |
| 26 | /// Whether the field is unsigned. |
| 27 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) unsignedrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#unsigned.: bool, |
| 28 | /// Whether the field is padding. |
| 29 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) paddingrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#padding.: bool, |
| 30 | /// The access of the field. |
| 31 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) accessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#access.: FieldAccessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#, |
| 32 | /// The type of the field. |
| 33 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) field_typerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#field_type.: FieldTyperust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldType#, |
| 34 | /// Whether the field is ignored. |
| 35 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) ignorerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitfieldField#ignore.: bool, |
| 36 | } |
| 37 | |
| 38 | /// Represents the type of field. |
| 39 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 40 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) enum FieldTyperust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldType# { |
| 41 | IntegerFieldTyperust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldType#IntegerFieldType#, |
| 42 | CustomFieldTyperust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldType#CustomFieldType#, |
| 43 | } |
| 44 | |
| 45 | /// Represents the `#[bits]` attribute. |
| 46 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 47 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) struct BitsAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute# { |
| 48 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#bits.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<u8>, |
| 49 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) default_value_exprrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#default_value_expr.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.104 crate/::Exprrust-analyzer cargo syn 2.0.104 expr/Expr#>, |
| 50 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) accessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#access.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<FieldAccessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#>, |
| 51 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) ignorerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#ignore.: bool, |
| 52 | } |
| 53 | |
| 54 | /// Represents the access of a field. |
| 55 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 56 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) enum FieldAccessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess# { |
| 57 | /// The field is read-only. |
| 58 | ReadOnlyrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#ReadOnly#, |
| 59 | /// The field is write-only. |
| 60 | WriteOnlyrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#WriteOnly#, |
| 61 | /// The field is read-write. |
| 62 | ReadWriterust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#ReadWrite#, |
| 63 | /// The field is inaccessible. |
| 64 | Nonerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#None#, |
| 65 | } |
| 66 | |
| 67 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for FieldAccessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess# { |
| 68 | type Errrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/impl#[FieldAccess][FromStr]Err# = (); |
| 69 | |
| 70 | fn from_strrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/impl#[FieldAccess][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/impl#[FieldAccess][FromStr], Selfrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/impl#[FieldAccess][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 71 | match s.to_ascii_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_ascii_lowercase().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() { |
| 72 | "ro" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(FieldAccessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#::ReadOnlyrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#ReadOnly#), |
| 73 | "wo" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(FieldAccessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#::WriteOnlyrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#WriteOnly#), |
| 74 | "rw" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(FieldAccessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#::ReadWriterust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#ReadWrite#), |
| 75 | "none" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(FieldAccessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#::Nonerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#None#), |
| 76 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()), |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | impl Parserust-analyzer cargo syn 2.0.104 parse/Parse# for BitsAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute# { |
| 82 | /// Parser a field with the '#[bits]' attribute. |
| 83 | fn parserust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/impl#[BitsAttribute][Parse]parse().(input: ParseStreamrust-analyzer cargo syn 2.0.104 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.104 crate/::Resultrust-analyzer cargo syn 2.0.104 error/Result#<Selfrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/impl#[BitsAttribute][Parse]> { |
| 84 | let mut bitfield_attribute_args = |
| 85 | BitsAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute# { bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#bits.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, default_value_exprrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#default_value_expr.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, accessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#access.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, ignorerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#ignore.: false }; |
| 86 | |
| 87 | // First check for the number of bits. |
| 88 | if input.peekrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]peek().(synrust-analyzer cargo syn 2.0.104 crate/::LitIntrust-analyzer cargo syn 2.0.104 lit/LitInt().) { |
| 89 | let num_bits = match input.parserust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.104 crate/::LitIntrust-analyzer cargo syn 2.0.104 lit/LitInt#>() { |
| 90 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(lit_int) => lit_int.base10_parserust-analyzer cargo syn 2.0.104 lit/impl#[LitInt]base10_parse().::<u8>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 91 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 92 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.104 crate/::Errorrust-analyzer cargo syn 2.0.104 error/Error#::newrust-analyzer cargo syn 2.0.104 error/impl#[Error]new().(input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), "Unable to parse field bits")); |
| 93 | } |
| 94 | }; |
| 95 | |
| 96 | // Move to the next argument. |
| 97 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().input.is_emptyrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]is_empty().() { |
| 98 | <Tokenrust-analyzer cargo syn 2.0.104 token/Token!![,]>::parserust-analyzer cargo syn 2.0.104 token/impl#[Comma][Parse]parse().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 99 | } |
| 100 | |
| 101 | bitfield_attribute_args.bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#bits. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(num_bits) |
| 102 | }; |
| 103 | |
| 104 | // Parse the remaining arguments which is in the form of `[key] = [val]`. |
| 105 | while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().input.is_emptyrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]is_empty().() { |
| 106 | // Parse the argument key. |
| 107 | let arg_ident = synrust-analyzer cargo syn 2.0.104 crate/::Identrust-analyzer cargo proc-macro2 1.0.95 Ident#::parserust-analyzer cargo syn 2.0.104 ident/parsing/impl#[Ident][Parse]parse().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 108 | |
| 109 | // Move to the key part of the argument. |
| 110 | <Tokenrust-analyzer cargo syn 2.0.104 token/Token!![=]>::parserust-analyzer cargo syn 2.0.104 token/impl#[Eq][Parse]parse().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 111 | |
| 112 | match arg_ident.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() { |
| 113 | "default" => { |
| 114 | let default_value_tokens = match input.parserust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.104 crate/::Exprrust-analyzer cargo syn 2.0.104 expr/Expr#>() { |
| 115 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(expr) => expr, |
| 116 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 117 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.104 crate/::Errorrust-analyzer cargo syn 2.0.104 error/Error#::newrust-analyzer cargo syn 2.0.104 error/impl#[Error]new().( |
| 118 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 119 | "Unable to parse default value", |
| 120 | )); |
| 121 | } |
| 122 | }; |
| 123 | bitfield_attribute_args.default_value_exprrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#default_value_expr. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(default_value_tokens); |
| 124 | } |
| 125 | "access" => { |
| 126 | let access_str = match input.parserust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.104 crate/::Identrust-analyzer cargo proc-macro2 1.0.95 Ident#>() { |
| 127 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ident) => ident.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 128 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 129 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.104 crate/::Errorrust-analyzer cargo syn 2.0.104 error/Error#::newrust-analyzer cargo syn 2.0.104 error/impl#[Error]new().( |
| 130 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 131 | "Unable to parse access value, expected 'ro', 'wo', 'rw', or 'none'", |
| 132 | )); |
| 133 | } |
| 134 | }; |
| 135 | let access = match FieldAccessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/FieldAccess#::from_strrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/impl#[FieldAccess][FromStr]from_str().(&access_str) { |
| 136 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(access) => access, |
| 137 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 138 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.104 crate/::Errorrust-analyzer cargo syn 2.0.104 error/Error#::newrust-analyzer cargo syn 2.0.104 error/impl#[Error]new().( |
| 139 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 140 | "Unable to parse access value, expected 'ro', 'wo', 'rw', or 'none'", |
| 141 | )); |
| 142 | } |
| 143 | }; |
| 144 | bitfield_attribute_args.accessrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#access. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(access); |
| 145 | } |
| 146 | "ignore" => { |
| 147 | bitfield_attribute_args.ignorerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#ignore. = match input.parserust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.104 crate/::LitBoolrust-analyzer cargo syn 2.0.104 lit/LitBool#>() { |
| 148 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(val) => val.valuerust-analyzer cargo syn 2.0.104 lit/LitBool#value., |
| 149 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 150 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(create_syn_errorrust-analyzer cargo bitfields-impl 1.0.0 create_syn_error().( |
| 151 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 152 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 153 | "Failed to parse the 'ignore' arg '{}', must be either 'true' or 'false'.", |
| 154 | err |
| 155 | ), |
| 156 | )); |
| 157 | } |
| 158 | }; |
| 159 | } |
| 160 | _ => {} |
| 161 | } |
| 162 | |
| 163 | // Move to the next argument. |
| 164 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().input.is_emptyrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]is_empty().() { |
| 165 | <Tokenrust-analyzer cargo syn 2.0.104 token/Token!![,]>::parserust-analyzer cargo syn 2.0.104 token/impl#[Comma][Parse]parse().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bitfield_attribute_args) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | #[cfg(test)] |
| 174 | mod testsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/tests/ { |
| 175 | use quoterust-analyzer cargo quote 1.0.40 crate/::quoterust-analyzer cargo quote 1.0.40 quote!; |
| 176 | |
| 177 | use superrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/::*; |
| 178 | |
| 179 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 180 | fn parse_bits_attributesrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/tests/parse_bits_attributes().() { |
| 181 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(8); |
| 182 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitsAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#>(args).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 183 | |
| 184 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(args.bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#bits., Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(8)); |
| 185 | } |
| 186 | |
| 187 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 188 | fn parse_bits_attributes_no_bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/tests/parse_bits_attributes_no_bits().() { |
| 189 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(); |
| 190 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitsAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#>(args).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 191 | |
| 192 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(args.bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_field/BitsAttribute#bits., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 193 | } |
| 194 | } |