Skip to content
Myr

Move Content's Clone impl from serde_core to serde

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 ff3aee4 · Browse files · 2 files+32 added−2 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+32 added−2 removed

  • other:+32 added−2 removed

2 files+32 added−2 removed

modified:serde/src/private/de.rs+32 added-1 removed
223 unmodified lines
224 _ => None,225 }226 }227228 fn content_clone<'de>(content: &Content<'de>) -> Content<'de> {229 match content {230 Content::Bool(b) => Content::Bool(*b),231 Content::U8(n) => Content::U8(*n),232 Content::U16(n) => Content::U16(*n),233 Content::U32(n) => Content::U32(*n),234 Content::U64(n) => Content::U64(*n),235 Content::I8(n) => Content::I8(*n),236 Content::I16(n) => Content::I16(*n),237 Content::I32(n) => Content::I32(*n),238 Content::I64(n) => Content::I64(*n),239 Content::F32(f) => Content::F32(*f),240 Content::F64(f) => Content::F64(*f),241 Content::Char(c) => Content::Char(*c),242 Content::String(s) => Content::String(s.clone()),243 Content::Str(s) => Content::Str(*s),244 Content::ByteBuf(b) => Content::ByteBuf(b.clone()),245 Content::Bytes(b) => Content::Bytes(b),246 Content::None => Content::None,247 Content::Some(content) => Content::Some(Box::new(content_clone(content))),248 Content::Unit => Content::Unit,249 Content::Newtype(content) => Content::Newtype(Box::new(content_clone(content))),250 Content::Seq(seq) => Content::Seq(seq.iter().map(content_clone).collect()),251 Content::Map(map) => Content::Map(252 map.iter()253 .map(|(k, v)| (content_clone(k), content_clone(v)))254 .collect(),255 ),256 }257 }258259 #[cold]260 fn content_unexpected<'a, 'de>(content: &'a Content<'de>) -> Unexpected<'a> {261 match *content {262 Content::Bool(b) => Unexpected::Bool(b),
1925 unmodified lines
2188 where2189 V: Visitor<'de, Value = Content<'de>>,2190 {2191 let _ = visitor;2161 Ok(self.content.clone())2192 Ok(content_clone(self.content))2193 }2194 }21952196 impl<'a, 'de, E> ContentRefDeserializer<'a, 'de, E> {
1032 unmodified lines
modified:serde_core/src/private/content.rs-1 removed
6 unmodified lines
7//8// Not public API. Use serde-value instead.9//10// Obsoleted by format-specific buffer types (https://github.com/serde-rs/serde/pull/2912).11#[derive(Clone)]11#[doc(hidden)]12pub enum Content<'de> {13 Bool(bool),14
249 unmodified lines