Repository: serde-rs/serde
File: serde/src/private/de.rs (Rust)

Code before:
    fn visit_content_seq_ref<'a, 'de, V, E>(
        content: &'a [Content<'de>],
        visitor: V,
    ) -> Result<V::Value, E>
    where
        V: Visitor<'de>,
        E: de::Error,
    {
        let seq = content.iter().map(ContentRefDeserializer::new);
        let mut seq_visitor = SeqDeserializer::new(seq);
        let value = tri!(visitor.visit_seq(&mut seq_visitor));
        tri!(seq_visitor.end());
        Ok(value)
    }

    fn visit_content_map_ref<'a, 'de, V, E>(
        content: &'a [(Content<'de>, Content<'de>)],
        visitor: V,
    ) -> Result<V::Value, E>
    where
        V: Visitor<'de>,
        E: de::Error,
    {
        fn content_ref_deserializer_pair<'a, 'de, E>(
            (k, v): &'a (Content<'de>, Content<'de>),
        ) -> (
            ContentRefDeserializer<'a, 'de, E>,
            ContentRefDeserializer<'a, 'de, E>,
        ) {
            (
                ContentRefDeserializer::new(k),
                ContentRefDeserializer::new(v),
            )
        }

        let map = content.iter().map(content_ref_deserializer_pair);
        let mut map_visitor = MapDeserializer::new(map);
        let value = tri!(visitor.visit_map(&mut map_visitor));
        tri!(map_visitor.end());
        Ok(value)
    }

    /// Used when deserializing an untagged enum because the content may need
    /// to be used more than once.
    impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E>
    where
        E: de::Error,
    {
        type Error = E;

        fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, E>

Review comment (suggestion):
I also tried adding:

```rust
impl<'a, A, B> Pair for &'a (A, B) {
    type First = &'a A;
    type Second = &'a B;
    fn split(self) -> (&'a A, &'a B) {
        (&self.0, &self.1)
    }
}
```

to make this function go away, like in the `visit_content_map` case. See #2823.

But somehow that made the rlib go back up from 111K to 124K, negating the benefit from #2821. I do not fully understand why this happens.

Code after:
        }
    }

    fn visit_content_seq_ref<'a, 'de, V, E>(
        content: &'a [Content<'de>],
        visitor: V,
    ) -> Result<V::Value, E>
    where
        V: Visitor<'de>,
        E: de::Error,
    {
        let mut seq_visitor = SeqDeserializer::new(content.iter());
        let value = tri!(visitor.visit_seq(&mut seq_visitor));
        tri!(seq_visitor.end());
        Ok(value)
    }

    fn visit_content_map_ref<'a, 'de, V, E>(
        content: &'a [(Content<'de>, Content<'de>)],
        visitor: V,
    ) -> Result<V::Value, E>
    where
        V: Visitor<'de>,
        E: de::Error,
    {
        fn content_ref_deserializer_pair<'a, 'de>(
            (k, v): &'a (Content<'de>, Content<'de>),
        ) -> (&'a Content<'de>, &'a Content<'de>) {
            (k, v)
        }

        let map = content.iter().map(content_ref_deserializer_pair);
        let mut map_visitor = MapDeserializer::new(map);
        let value = tri!(visitor.visit_map(&mut map_visitor));
        tri!(map_visitor.end());
        Ok(value)
    }

    /// Used when deserializing an untagged enum because the content may need
    /// to be used more than once.
    impl<'de, 'a, E> Deserializer<'de> for ContentRefDeserializer<'a, 'de, E>
    where
        E: de::Error,
    {
        type Error = E;

        fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, E>
        where
            V: Visitor<'de>,
        {
            match *self.content {