comparison formats/src/th06/std.rs @ 776:94033091458b

formats: Update to ${concat(…)} to build on current nightly ${concat(…)} replaces the removed concat_idents!() macro, but doesn’t support being used in nested repetitions for now. We can remove the gen_match!() macro once this is supported again.
author Link Mauve <linkmauve@linkmauve.fr>
date Tue, 14 Oct 2025 12:41:29 +0000
parents d08eb4c9fce3
children ee09657d3789
comparison
equal deleted inserted replaced
775:28d8b892fd06 776:94033091458b
122 pub fn from_slice(data: &[u8]) -> IResult<&[u8], Stage> { 122 pub fn from_slice(data: &[u8]) -> IResult<&[u8], Stage> {
123 parse_stage(data) 123 parse_stage(data)
124 } 124 }
125 } 125 }
126 126
127 macro_rules! gen_match {
128 ($arg_type:ident) => {
129 ${concat(le_, $arg_type)}
130 };
131 }
132
127 macro_rules! declare_stage_instructions { 133 macro_rules! declare_stage_instructions {
128 ($($opcode:tt => fn $name:ident($($arg:ident: $arg_type:ident),*)),*,) => { 134 ($($opcode:tt => fn $name:ident($($arg:ident: $arg_type:ident),*)),*,) => {
129 /// Available instructions in an `Stage`. 135 /// Available instructions in an `Stage`.
130 #[allow(missing_docs)] 136 #[allow(missing_docs)]
131 #[derive(Debug, Clone, Copy)] 137 #[derive(Debug, Clone, Copy)]
139 let mut i = &input[..]; 145 let mut i = &input[..];
140 let instr = match opcode { 146 let instr = match opcode {
141 $( 147 $(
142 $opcode => { 148 $opcode => {
143 $( 149 $(
144 let (i2, $arg) = concat_idents!(le_, $arg_type)(i)?; 150 let (i2, $arg) = gen_match!($arg_type)(i)?;
145 i = i2; 151 i = i2;
146 )* 152 )*
147 Instruction::$name($($arg),*) 153 Instruction::$name($($arg),*)
148 } 154 }
149 )* 155 )*