Skip to content

Commit

Permalink
Remove constructors for FlatMapAccess and FlatStructAccess
Browse files Browse the repository at this point in the history
They are used only in one place each, so for simplifying understanding it is better to inline them
  • Loading branch information
Mingun committed May 8, 2023
1 parent a901f50 commit e11d01f
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions serde/src/private/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2775,7 +2775,11 @@ where
where
V: Visitor<'de>,
{
visitor.visit_map(FlatMapAccess::new(self.0.iter()))
visitor.visit_map(FlatMapAccess {
iter: self.0.iter(),
pending_content: None,
_marker: PhantomData,
})
}

fn deserialize_struct<V>(
Expand All @@ -2787,7 +2791,12 @@ where
where
V: Visitor<'de>,
{
visitor.visit_map(FlatStructAccess::new(self.0.iter_mut(), fields))
visitor.visit_map(FlatStructAccess {
iter: self.0.iter_mut(),
pending_content: None,
fields: fields,
_marker: PhantomData,
})
}

fn deserialize_newtype_struct<V>(self, _name: &str, visitor: V) -> Result<V::Value, Self::Error>
Expand Down Expand Up @@ -2847,19 +2856,6 @@ struct FlatMapAccess<'a, 'de: 'a, E> {
_marker: PhantomData<E>,
}

#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, 'de, E> FlatMapAccess<'a, 'de, E> {
fn new(
iter: slice::Iter<'a, Option<(Content<'de>, Content<'de>)>>,
) -> FlatMapAccess<'a, 'de, E> {
FlatMapAccess {
iter: iter,
pending_content: None,
_marker: PhantomData,
}
}
}

#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, 'de, E> MapAccess<'de> for FlatMapAccess<'a, 'de, E>
where
Expand Down Expand Up @@ -2904,21 +2900,6 @@ struct FlatStructAccess<'a, 'de: 'a, E> {
_marker: PhantomData<E>,
}

#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, 'de, E> FlatStructAccess<'a, 'de, E> {
fn new(
iter: slice::IterMut<'a, Option<(Content<'de>, Content<'de>)>>,
fields: &'static [&'static str],
) -> FlatStructAccess<'a, 'de, E> {
FlatStructAccess {
iter: iter,
pending_content: None,
fields: fields,
_marker: PhantomData,
}
}
}

#[cfg(any(feature = "std", feature = "alloc"))]
impl<'a, 'de, E> MapAccess<'de> for FlatStructAccess<'a, 'de, E>
where
Expand Down

0 comments on commit e11d01f

Please sign in to comment.