Document tuple impls as fake variadic
This commit is contained in:
parent
376185458b
commit
5d3c563d46
@ -1393,7 +1393,19 @@ array_impls! {
|
|||||||
macro_rules! tuple_impls {
|
macro_rules! tuple_impls {
|
||||||
($($len:tt => ($($n:tt $name:ident)+))+) => {
|
($($len:tt => ($($n:tt $name:ident)+))+) => {
|
||||||
$(
|
$(
|
||||||
impl<'de, $($name: Deserialize<'de>),+> Deserialize<'de> for ($($name,)+) {
|
#[cfg_attr(docsrs, doc(hidden))]
|
||||||
|
impl<'de, $($name),+> Deserialize<'de> for ($($name,)+)
|
||||||
|
where
|
||||||
|
$($name: Deserialize<'de>,)+
|
||||||
|
{
|
||||||
|
tuple_impl_body!($len => ($($n $name)+));
|
||||||
|
}
|
||||||
|
)+
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! tuple_impl_body {
|
||||||
|
($len:tt => ($($n:tt $name:ident)+)) => {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
@ -1462,13 +1474,22 @@ macro_rules! tuple_impls {
|
|||||||
|
|
||||||
deserializer.deserialize_tuple($len, TupleInPlaceVisitor(place))
|
deserializer.deserialize_tuple($len, TupleInPlaceVisitor(place))
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
)+
|
|
||||||
}
|
#[cfg_attr(docsrs, doc(fake_variadic))]
|
||||||
|
#[cfg_attr(
|
||||||
|
docsrs,
|
||||||
|
doc = "This trait is implemented for tuples up to 16 items long."
|
||||||
|
)]
|
||||||
|
impl<'de, T> Deserialize<'de> for (T,)
|
||||||
|
where
|
||||||
|
T: Deserialize<'de>,
|
||||||
|
{
|
||||||
|
tuple_impl_body!(1 => (0 T));
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple_impls! {
|
tuple_impls! {
|
||||||
1 => (0 T0)
|
|
||||||
2 => (0 T0 1 T1)
|
2 => (0 T0 1 T1)
|
||||||
3 => (0 T0 1 T1 2 T2)
|
3 => (0 T0 1 T1 2 T2)
|
||||||
4 => (0 T0 1 T1 2 T2 3 T3)
|
4 => (0 T0 1 T1 2 T2 3 T3)
|
||||||
|
@ -99,7 +99,8 @@
|
|||||||
// Support using Serde without the standard library!
|
// Support using Serde without the standard library!
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
// Show which crate feature enables conditionally compiled APIs in documentation.
|
// Show which crate feature enables conditionally compiled APIs in documentation.
|
||||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
#![cfg_attr(docsrs, feature(doc_cfg, rustdoc_internals))]
|
||||||
|
#![cfg_attr(docsrs, allow(internal_features))]
|
||||||
// Unstable functionality only if the user asks for it. For tracking and
|
// Unstable functionality only if the user asks for it. For tracking and
|
||||||
// discussion of these features please refer to this issue:
|
// discussion of these features please refer to this issue:
|
||||||
//
|
//
|
||||||
|
@ -386,10 +386,19 @@ impl Serialize for ! {
|
|||||||
macro_rules! tuple_impls {
|
macro_rules! tuple_impls {
|
||||||
($($len:expr => ($($n:tt $name:ident)+))+) => {
|
($($len:expr => ($($n:tt $name:ident)+))+) => {
|
||||||
$(
|
$(
|
||||||
|
#[cfg_attr(docsrs, doc(hidden))]
|
||||||
impl<$($name),+> Serialize for ($($name,)+)
|
impl<$($name),+> Serialize for ($($name,)+)
|
||||||
where
|
where
|
||||||
$($name: Serialize,)+
|
$($name: Serialize,)+
|
||||||
{
|
{
|
||||||
|
tuple_impl_body!($len => ($($n)+));
|
||||||
|
}
|
||||||
|
)+
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! tuple_impl_body {
|
||||||
|
($len:expr => ($($n:tt)+)) => {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
@ -401,13 +410,22 @@ macro_rules! tuple_impls {
|
|||||||
)+
|
)+
|
||||||
tuple.end()
|
tuple.end()
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
)+
|
|
||||||
}
|
#[cfg_attr(docsrs, doc(fake_variadic))]
|
||||||
|
#[cfg_attr(
|
||||||
|
docsrs,
|
||||||
|
doc = "This trait is implemented for tuples up to 16 items long."
|
||||||
|
)]
|
||||||
|
impl<T> Serialize for (T,)
|
||||||
|
where
|
||||||
|
T: Serialize,
|
||||||
|
{
|
||||||
|
tuple_impl_body!(1 => (0));
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple_impls! {
|
tuple_impls! {
|
||||||
1 => (0 T0)
|
|
||||||
2 => (0 T0 1 T1)
|
2 => (0 T0 1 T1)
|
||||||
3 => (0 T0 1 T1 2 T2)
|
3 => (0 T0 1 T1 2 T2)
|
||||||
4 => (0 T0 1 T1 2 T2 3 T3)
|
4 => (0 T0 1 T1 2 T2 3 T3)
|
||||||
|
Loading…
Reference in New Issue
Block a user