Remove the no_std implementation of collect_str
This commit is contained in:
parent
92bc23e484
commit
f05368ed24
@ -654,8 +654,9 @@ pub trait Serializer: Sized {
|
|||||||
|
|
||||||
/// Serialize a string produced by an implementation of `Display`.
|
/// Serialize a string produced by an implementation of `Display`.
|
||||||
///
|
///
|
||||||
/// The default implementation returns an error unconditionally when
|
/// Serializers that use `no_std` are required to provide an implementation
|
||||||
/// compiled with `no_std`.
|
/// of this method. If no more sensible behavior is possible, the
|
||||||
|
/// implementation is expected to return an error.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use serde::{Serialize, Serializer};
|
/// # use serde::{Serialize, Serializer};
|
||||||
@ -676,13 +677,7 @@ pub trait Serializer: Sized {
|
|||||||
/// ```
|
/// ```
|
||||||
#[cfg(not(any(feature = "std", feature = "collections")))]
|
#[cfg(not(any(feature = "std", feature = "collections")))]
|
||||||
fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
|
fn collect_str<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
|
||||||
where T: Display
|
where T: Display;
|
||||||
{
|
|
||||||
// TODO https://github.com/serde-rs/serde/issues/805
|
|
||||||
// Remove this impl and force no_std formats to implement collect_str.
|
|
||||||
let _ = value;
|
|
||||||
Err(Error::custom("this no_std format does not support serializing strings with collect_str"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returned from `Serializer::serialize_seq` and
|
/// Returned from `Serializer::serialize_seq` and
|
||||||
|
@ -312,4 +312,11 @@ impl<S> Serializer for TaggedSerializer<S>
|
|||||||
try!(map.serialize_key(inner_variant));
|
try!(map.serialize_key(inner_variant));
|
||||||
Ok(SerializeStructVariantAsMapValue::new(map, inner_variant, len))
|
Ok(SerializeStructVariantAsMapValue::new(map, inner_variant, len))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(feature = "std", feature = "collections")))]
|
||||||
|
fn collect_str<T: ?Sized>(self, _: &T) -> Result<Self::Ok, Self::Error>
|
||||||
|
where T: Display
|
||||||
|
{
|
||||||
|
Err(self.bad_type(Unsupported::String))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user