| 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 synrust-analyzer cargo syn 2.0.104 crate/::Tokenrust-analyzer cargo syn 2.0.104 token/Token!; |
| 4 | 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#}; |
| 5 | |
| 6 | use craterust-analyzer cargo bitfields-impl 1.0.0 crate/::create_syn_errorrust-analyzer cargo bitfields-impl 1.0.0 create_syn_error().; |
| 7 | use craterust-analyzer cargo bitfields-impl 1.0.0 crate/::parsingrust-analyzer cargo bitfields-impl 1.0.0 parsing/::typesrust-analyzer cargo bitfields-impl 1.0.0 parsing/types/::{get_bits_from_typerust-analyzer cargo bitfields-impl 1.0.0 parsing/types/get_bits_from_type()., is_supported_bitfield_typerust-analyzer cargo bitfields-impl 1.0.0 parsing/types/is_supported_bitfield_type().}; |
| 8 | |
| 9 | /// Represents the `#[bitfield]` attribute. |
| 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 BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute# { |
| 12 | /// The integer type of the bitfield. |
| 13 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) tyrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#ty.: synrust-analyzer cargo syn 2.0.104 crate/::Typerust-analyzer cargo syn 2.0.104 ty/Type#, |
| 14 | /// The number of bits of the bitfield. |
| 15 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#bits.: u8, |
| 16 | /// The order of the bits in the bitfield. |
| 17 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) bit_orderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#bit_order.: BitOrderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#, |
| 18 | /// The endianness of the [`from_bits`] input. |
| 19 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) from_endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#from_endian.: Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#, |
| 20 | /// The endianness of the [`into_bits`] output. |
| 21 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) into_endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#into_endian.: Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#, |
| 22 | /// Whether to generate the `new` or `new_without_defaults` function. |
| 23 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_new_funcrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_new_func.: bool, |
| 24 | /// Whether to generate the `into_bits` function. |
| 25 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_into_bits_funcrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_into_bits_func.: bool, |
| 26 | /// Whether to generate the `from_bits` function. |
| 27 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_from_bits_funcrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_from_bits_func.: bool, |
| 28 | /// Whether to generate the from trait functions. |
| 29 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_from_trait_funcsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_from_trait_funcs.: bool, |
| 30 | /// Whether to generate the `default` implementation. |
| 31 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_default_implrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_default_impl.: bool, |
| 32 | /// Whether to generate the builder. |
| 33 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_builderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_builder.: bool, |
| 34 | /// Whether to generate the `debug_impl` function. |
| 35 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_debug_implrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_debug_impl.: bool, |
| 36 | /// Whether to generate the bit operations. |
| 37 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_bit_opsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_bit_ops.: bool, |
| 38 | /// Whether to generate the set bits implementation. |
| 39 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_set_bits_implrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_set_bits_impl.: bool, |
| 40 | /// Whether to generate the clear bits implementation. |
| 41 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_clear_bits_implrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_clear_bits_impl.: bool, |
| 42 | /// Whether to generate the `to_builder` function. |
| 43 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_to_builderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_to_builder.: bool, |
| 44 | /// Whether to generate the `neg` function. |
| 45 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) generate_neg_funcrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_neg_func.: bool, |
| 46 | } |
| 47 | |
| 48 | /// The order of the bits in the bitfield. |
| 49 | /// |
| 50 | /// If the order is `Lsb`, the top most field will be the least significant bit |
| 51 | /// and the bottom most field is the most significant bit. If the order is |
| 52 | /// `Msb`, the top most field will be the most significant bit and the bottom |
| 53 | /// most field is the least significant bit. |
| 54 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, 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:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 55 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) enum BitOrderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder# { |
| 56 | Lsbrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#Lsb#, |
| 57 | Msbrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#Msb#, |
| 58 | } |
| 59 | |
| 60 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for BitOrderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder# { |
| 61 | type Errrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[BitOrder][FromStr]Err# = (); |
| 62 | |
| 63 | fn from_strrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[BitOrder][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_attribute/impl#[BitOrder][FromStr], Selfrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[BitOrder][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 64 | 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().() { |
| 65 | "lsb" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(BitOrderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#::Lsbrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#Lsb#), |
| 66 | "msb" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(BitOrderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#::Msbrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#Msb#), |
| 67 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()), |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /// The endianness of the bytes. |
| 73 | #[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:)] |
| 74 | pub(craterust-analyzer cargo bitfields-impl 1.0.0 crate/) enum Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian# { |
| 75 | Littlerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#Little#, |
| 76 | Bigrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#Big#, |
| 77 | } |
| 78 | |
| 79 | impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian# { |
| 80 | type Errrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[Endian][FromStr]Err# = (); |
| 81 | |
| 82 | fn from_strrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[Endian][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_attribute/impl#[Endian][FromStr], Selfrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[Endian][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> { |
| 83 | 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().() { |
| 84 | "little" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#::Littlerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#Little#), |
| 85 | "big" => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#::Bigrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#Big#), |
| 86 | _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(()), |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | impl Parserust-analyzer cargo syn 2.0.104 parse/Parse# for BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute# { |
| 92 | fn parserust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[BitfieldAttribute][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_attribute/impl#[BitfieldAttribute][Parse]> { |
| 93 | // Get the type of the bitfield. |
| 94 | let ty = match input.parserust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]parse().() { |
| 95 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ty) => ty, |
| 96 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 97 | 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().( |
| 98 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 99 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 100 | "Failed to parse the 'bitfield' attribute field type: {}. The 'bitfield' attribute must have an unsigned integer type as its first argument.", |
| 101 | err |
| 102 | ), |
| 103 | )); |
| 104 | } |
| 105 | }; |
| 106 | |
| 107 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_supported_bitfield_typerust-analyzer cargo bitfields-impl 1.0.0 parsing/types/is_supported_bitfield_type().(&ty) { |
| 108 | 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().( |
| 109 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 110 | "The 'bitfield' attribute must have an unsigned integer type as its first argument.", |
| 111 | )); |
| 112 | } |
| 113 | |
| 114 | let bits = get_bits_from_typerust-analyzer cargo bitfields-impl 1.0.0 parsing/types/get_bits_from_type().(&ty)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 115 | |
| 116 | // Move to the next argument. |
| 117 | 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().() { |
| 118 | <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().; |
| 119 | } |
| 120 | |
| 121 | let mut bit_order = BitOrderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#::Lsbrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#Lsb#; |
| 122 | let mut from_endian = Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#::Bigrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#Big#; |
| 123 | let mut into_endian = Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#::Bigrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#Big#; |
| 124 | let mut generate_new_func = true; |
| 125 | let mut generate_into_bits_func = true; |
| 126 | let mut generate_from_bits_func = true; |
| 127 | let mut generate_from_trait_funcs = true; |
| 128 | let mut generate_default_impl = true; |
| 129 | let mut generate_builder = true; |
| 130 | let mut generate_debug_impl = true; |
| 131 | let mut generate_bit_ops = false; |
| 132 | let mut generate_set_bits_impl = true; |
| 133 | let mut generate_clear_bits_impl = true; |
| 134 | let mut generate_to_builder = false; |
| 135 | let mut generate_neg_func = false; |
| 136 | |
| 137 | // Parse the remaining arguments which is in the form of `[key] = [val]`. |
| 138 | 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().() { |
| 139 | // Parse the argument key. |
| 140 | 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().; |
| 141 | |
| 142 | // Move to the key part of the argument. |
| 143 | <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().; |
| 144 | |
| 145 | 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().() { |
| 146 | "order" => { |
| 147 | let order_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#>() { |
| 148 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(order) => order.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 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!!("Failed to parse the 'order' arg '{}'.", err), |
| 153 | )); |
| 154 | } |
| 155 | }; |
| 156 | bit_order = match BitOrderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitOrder#::from_strrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[BitOrder][FromStr]from_str().(&order_str) { |
| 157 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(order) => order, |
| 158 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 159 | 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().( |
| 160 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 161 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 162 | "Invalid order: '{}', must be either 'lsb' or 'msb'.", |
| 163 | order_str |
| 164 | ), |
| 165 | )); |
| 166 | } |
| 167 | }; |
| 168 | } |
| 169 | // Doesn't apply to user passed functions. |
| 170 | "from_endian" => { |
| 171 | let from_endian_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#>() { |
| 172 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(from_endian) => from_endian.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 173 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 174 | 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().( |
| 175 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 176 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 177 | "Failed to parse the 'from_endian' arg '{}', must be either 'little' or 'big'.", |
| 178 | err |
| 179 | ), |
| 180 | )); |
| 181 | } |
| 182 | }; |
| 183 | from_endian = match Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#::from_strrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[Endian][FromStr]from_str().(&from_endian_str) { |
| 184 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(endian) => endian, |
| 185 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 186 | 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().( |
| 187 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 188 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 189 | "Invalid endian: '{}', must be either 'little' or 'big'.", |
| 190 | from_endian_str |
| 191 | ), |
| 192 | )); |
| 193 | } |
| 194 | }; |
| 195 | } |
| 196 | // Doesn't apply to user passed functions. |
| 197 | "into_endian" => { |
| 198 | let into_endian_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#>() { |
| 199 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(into_endian) => into_endian.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 200 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 201 | 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().( |
| 202 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 203 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 204 | "Failed to parse the 'into_endian' arg '{}', must be either 'little' or 'big'.", |
| 205 | err |
| 206 | ), |
| 207 | )); |
| 208 | } |
| 209 | }; |
| 210 | into_endian = match Endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/Endian#::from_strrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[Endian][FromStr]from_str().(&into_endian_str) { |
| 211 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(endian) => endian, |
| 212 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => { |
| 213 | 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().( |
| 214 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 215 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 216 | "Invalid endian: '{}', must be either 'little' or 'big'.", |
| 217 | into_endian_str |
| 218 | ), |
| 219 | )); |
| 220 | } |
| 221 | }; |
| 222 | } |
| 223 | "new" => { |
| 224 | generate_new_func = 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#>() { |
| 225 | 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., |
| 226 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 227 | 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().( |
| 228 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 229 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 230 | "Failed to parse the 'new' arg '{}', must be either 'true' or 'false'.", |
| 231 | err |
| 232 | ), |
| 233 | )); |
| 234 | } |
| 235 | }; |
| 236 | } |
| 237 | "into_bits" => { |
| 238 | generate_into_bits_func = 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#>() { |
| 239 | 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., |
| 240 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 241 | 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().( |
| 242 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 243 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 244 | "Failed to parse the 'into_bits' arg '{}', must be either 'true' or 'false'.", |
| 245 | err |
| 246 | ), |
| 247 | )); |
| 248 | } |
| 249 | }; |
| 250 | } |
| 251 | "from_bits" => { |
| 252 | generate_from_bits_func = 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#>() { |
| 253 | 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., |
| 254 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 255 | 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().( |
| 256 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 257 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 258 | "Failed to parse the 'from_bits' arg '{}', must be either 'true' or 'false'.", |
| 259 | err |
| 260 | ), |
| 261 | )); |
| 262 | } |
| 263 | }; |
| 264 | } |
| 265 | "from" => { |
| 266 | generate_from_trait_funcs = 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#>() { |
| 267 | 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., |
| 268 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 269 | 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().( |
| 270 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 271 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 272 | "Failed to parse the 'from_type' arg '{}', must be either 'true' or 'false'.", |
| 273 | err |
| 274 | ), |
| 275 | )); |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | "default" => { |
| 280 | generate_default_impl = 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#>() { |
| 281 | 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., |
| 282 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 283 | 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().( |
| 284 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 285 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 286 | "Failed to parse the 'default' arg '{}', must be either 'true' or 'false'.", |
| 287 | err |
| 288 | ), |
| 289 | )); |
| 290 | } |
| 291 | }; |
| 292 | } |
| 293 | "builder" => { |
| 294 | generate_builder = 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#>() { |
| 295 | 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., |
| 296 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 297 | 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().( |
| 298 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 299 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 300 | "Failed to parse the 'builder' arg '{}', must be either 'true' or 'false'.", |
| 301 | err |
| 302 | ), |
| 303 | )); |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | "to_builder" => { |
| 308 | generate_to_builder = 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#>() { |
| 309 | 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., |
| 310 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 311 | 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().( |
| 312 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 313 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 314 | "Failed to parse the 'builder' arg '{}', must be either 'true' or 'false'.", |
| 315 | err |
| 316 | ), |
| 317 | )); |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | "debug" => { |
| 322 | generate_debug_impl = 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#>() { |
| 323 | 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., |
| 324 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 325 | 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().( |
| 326 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 327 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 328 | "Failed to parse the 'debug' arg '{}', must be either 'true', or 'false'.", |
| 329 | err |
| 330 | ), |
| 331 | )); |
| 332 | } |
| 333 | }; |
| 334 | } |
| 335 | "bit_ops" => { |
| 336 | generate_bit_ops = 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#>() { |
| 337 | 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., |
| 338 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 339 | 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().( |
| 340 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 341 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 342 | "Failed to parse the 'big_ops' arg '{}', must be either 'true', or 'false'.", |
| 343 | err |
| 344 | ), |
| 345 | )); |
| 346 | } |
| 347 | }; |
| 348 | } |
| 349 | "set_bits" => { |
| 350 | generate_set_bits_impl = 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#>() { |
| 351 | 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., |
| 352 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 353 | 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().( |
| 354 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 355 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 356 | "Failed to parse the 'set_bits' arg '{}', must be either 'true', or 'false'.", |
| 357 | err |
| 358 | ), |
| 359 | )); |
| 360 | } |
| 361 | }; |
| 362 | } |
| 363 | "clear_bits" => { |
| 364 | generate_clear_bits_impl = 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#>() { |
| 365 | 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., |
| 366 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 367 | 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().( |
| 368 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 369 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 370 | "Failed to parse the 'set_bits' arg '{}', must be either 'true', or 'false'.", |
| 371 | err |
| 372 | ), |
| 373 | )); |
| 374 | } |
| 375 | }; |
| 376 | } |
| 377 | "neg" => { |
| 378 | generate_neg_func = 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#>() { |
| 379 | 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., |
| 380 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 381 | 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().( |
| 382 | input.spanrust-analyzer cargo syn 2.0.104 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 383 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 384 | "Failed to parse the 'neg' arg '{}', must be either 'true', or 'false'.", |
| 385 | err |
| 386 | ), |
| 387 | )); |
| 388 | } |
| 389 | }; |
| 390 | } |
| 391 | _ => { |
| 392 | 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().( |
| 393 | arg_ident.spanrust-analyzer cargo proc-macro2 1.0.95 impl#[Ident]span().(), |
| 394 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Unknown 'bitfield' argument: {}", arg_ident), |
| 395 | )); |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | // Move to the next argument. |
| 400 | 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().() { |
| 401 | <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().; |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/impl#[BitfieldAttribute][Parse] { |
| 406 | tyrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#ty., |
| 407 | bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#bits., |
| 408 | bit_orderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#bit_order., |
| 409 | from_endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#from_endian., |
| 410 | into_endianrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#into_endian., |
| 411 | generate_new_funcrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_new_func., |
| 412 | generate_into_bits_funcrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_into_bits_func., |
| 413 | generate_from_bits_funcrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_from_bits_func., |
| 414 | generate_default_implrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_default_impl., |
| 415 | generate_debug_implrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_debug_impl., |
| 416 | generate_builderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_builder., |
| 417 | generate_from_trait_funcsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_from_trait_funcs., |
| 418 | generate_bit_opsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_bit_ops., |
| 419 | generate_set_bits_implrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_set_bits_impl., |
| 420 | generate_clear_bits_implrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_clear_bits_impl., |
| 421 | generate_to_builderrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_to_builder., |
| 422 | generate_neg_funcrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#generate_neg_func., |
| 423 | }) |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | #[cfg(test)] |
| 428 | mod testsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/tests/ { |
| 429 | use quoterust-analyzer cargo quote 1.0.40 crate/::quoterust-analyzer cargo quote 1.0.40 quote!; |
| 430 | |
| 431 | use superrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/::*; |
| 432 | |
| 433 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 434 | fn test_parse_bitfield_no_args_returns_errorrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/tests/test_parse_bitfield_no_args_returns_error().() { |
| 435 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(); |
| 436 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#>(args); |
| 437 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 438 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().( |
| 439 | "The 'bitfield' attribute must have an unsigned integer type as its first argument" |
| 440 | )); |
| 441 | } |
| 442 | |
| 443 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 444 | fn test_parse_bitfield_invalid_type_arg_returns_errorrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/tests/test_parse_bitfield_invalid_type_arg_returns_error().() { |
| 445 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(eff); |
| 446 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#>(args); |
| 447 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 448 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().( |
| 449 | "The 'bitfield' attribute must have an unsigned integer type as its first argument." |
| 450 | )); |
| 451 | |
| 452 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(i32); |
| 453 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#>(args); |
| 454 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().()); |
| 455 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().( |
| 456 | "The 'bitfield' attribute must have an unsigned integer type as its first argument." |
| 457 | )); |
| 458 | } |
| 459 | |
| 460 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 461 | fn test_parse_bitfield_unsigned_integer_typesrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/tests/test_parse_bitfield_unsigned_integer_types().() { |
| 462 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(u8); |
| 463 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#>(args); |
| 464 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 465 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(args.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#bits., 8); |
| 466 | |
| 467 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(u16); |
| 468 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#>(args); |
| 469 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 470 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(args.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#bits., 16); |
| 471 | |
| 472 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(u32); |
| 473 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#>(args); |
| 474 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 475 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(args.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#bits., 32); |
| 476 | |
| 477 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(u64); |
| 478 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#>(args); |
| 479 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 480 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(args.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#bits., 64); |
| 481 | |
| 482 | let args = quoterust-analyzer cargo quote 1.0.40 quote!!(u128); |
| 483 | let args = synrust-analyzer cargo syn 2.0.104 crate/::parse2rust-analyzer cargo syn 2.0.104 parse2().::<BitfieldAttributerust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#>(args); |
| 484 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(args.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 485 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(args.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().bitsrust-analyzer cargo bitfields-impl 1.0.0 parsing/bitfield_attribute/BitfieldAttribute#bits., 128); |
| 486 | } |
| 487 | } |