Skip to content
Myr

Unindent implementation inside tuple_impl_body macro

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 5d3c563 · Browse files · 2 files+63 added−63 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+63 added−63 removed

  • other:+63 added−63 removed

2 files+63 added−63 removed

modified:serde/src/de/impls.rs+52 added-52 removed
1404 unmodified lines
1405}14061407macro_rules! tuple_impl_body {1408 ($len:tt => ($($n:tt $name:ident)+)) => {1409 #[inline]1410 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>1411 where1412 D: Deserializer<'de>,1413 {1414 struct TupleVisitor<$($name,)+> {1415 marker: PhantomData<($($name,)+)>,1416 }14171418 impl<'de, $($name: Deserialize<'de>),+> Visitor<'de> for TupleVisitor<$($name,)+> {1419 type Value = ($($name,)+);14201421 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {1422 formatter.write_str(concat!("a tuple of size ", $len))1423 }14241425 #[inline]1410 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>1426 #[allow(non_snake_case)]1427 fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>1428 where1412 D: Deserializer<'de>,1429 A: SeqAccess<'de>,1430 {1414 struct TupleVisitor<$($name,)+> {1415 marker: PhantomData<($($name,)+)>,1416 }1431 $(1432 let $name = match tri!(seq.next_element()) {1433 Some(value) => value,1434 None => return Err(Error::invalid_length($n, &self)),1435 };1436 )+14371418 impl<'de, $($name: Deserialize<'de>),+> Visitor<'de> for TupleVisitor<$($name,)+> {1419 type Value = ($($name,)+);1438 Ok(($($name,)+))1439 }1440 }14411421 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {1422 formatter.write_str(concat!("a tuple of size ", $len))1423 }1442 deserializer.deserialize_tuple($len, TupleVisitor { marker: PhantomData })1443 }14441425 #[inline]1426 #[allow(non_snake_case)]1427 fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>1428 where1429 A: SeqAccess<'de>,1430 {1431 $(1432 let $name = match tri!(seq.next_element()) {1433 Some(value) => value,1434 None => return Err(Error::invalid_length($n, &self)),1435 };1436 )+1445 #[inline]1446 fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error>1447 where1448 D: Deserializer<'de>,1449 {1450 struct TupleInPlaceVisitor<'a, $($name: 'a,)+>(&'a mut ($($name,)+));14511438 Ok(($($name,)+))1439 }1440 }1452 impl<'a, 'de, $($name: Deserialize<'de>),+> Visitor<'de> for TupleInPlaceVisitor<'a, $($name,)+> {1453 type Value = ();14541442 deserializer.deserialize_tuple($len, TupleVisitor { marker: PhantomData })1455 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {1456 formatter.write_str(concat!("a tuple of size ", $len))1457 }14581459 #[inline]1446 fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error>1460 #[allow(non_snake_case)]1461 fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>1462 where1448 D: Deserializer<'de>,1463 A: SeqAccess<'de>,1464 {1450 struct TupleInPlaceVisitor<'a, $($name: 'a,)+>(&'a mut ($($name,)+));14511452 impl<'a, 'de, $($name: Deserialize<'de>),+> Visitor<'de> for TupleInPlaceVisitor<'a, $($name,)+> {1453 type Value = ();14541455 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {1456 formatter.write_str(concat!("a tuple of size ", $len))1465 $(1466 if tri!(seq.next_element_seed(InPlaceSeed(&mut (self.0).$n))).is_none() {1467 return Err(Error::invalid_length($n, &self));1468 }1469 )+14701459 #[inline]1460 #[allow(non_snake_case)]1461 fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error>1462 where1463 A: SeqAccess<'de>,1464 {1465 $(1466 if tri!(seq.next_element_seed(InPlaceSeed(&mut (self.0).$n))).is_none() {1467 return Err(Error::invalid_length($n, &self));1468 }1469 )+14701471 Ok(())1471 Ok(())1472 }1473 }14741475 deserializer.deserialize_tuple($len, TupleInPlaceVisitor(place))1472 }1473 }14741475 deserializer.deserialize_tuple($len, TupleInPlaceVisitor(place))1476 }1477 };1478}14791480#[cfg_attr(docsrs, doc(fake_variadic))]
1717 unmodified lines
modified:serde/src/ser/impls.rs+11 added-11 removed
397 unmodified lines
398}399400macro_rules! tuple_impl_body {401 ($len:expr => ($($n:tt)+)) => {402 #[inline]403 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>404 where405 S: Serializer,406 {407 let mut tuple = tri!(serializer.serialize_tuple($len));408 $(409 tri!(tuple.serialize_element(&self.$n));410 )+411 tuple.end()412 }402 #[inline]403 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>404 where405 S: Serializer,406 {407 let mut tuple = tri!(serializer.serialize_tuple($len));408 $(409 tri!(tuple.serialize_element(&self.$n));410 )+411 tuple.end()412 }413 };414}415416#[cfg_attr(docsrs, doc(fake_variadic))]
696 unmodified lines