Use count! macro in tuple length computation
This commit is contained in:
parent
19288951e1
commit
6f711a37e3
@ -591,9 +591,8 @@ impl<S: Encoder, $($name: Encodable<S>),+> Encodable<S> for ($($name,)+) {
|
||||
#[allow(non_snake_case)]
|
||||
fn encode(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
let ($(ref $name,)+) = *self;
|
||||
let mut n = 0;
|
||||
$(let $name = $name; n += 1;)+
|
||||
s.emit_tuple(n, |s| {
|
||||
let len: usize = count!($($name)+);
|
||||
s.emit_tuple(len, |s| {
|
||||
let mut i = 0;
|
||||
$(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s))?;)+
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user