mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 05:58:01 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d960571439 | |||
| 1ccc58e2aa | |||
| 34b39083bc | |||
| 48f4deac55 | |||
| 9a0f05d00d | |||
| b47e1a6dc3 | |||
| 39c7797633 | |||
| 368784949e | |||
| 74cf80989d | |||
| f0b4735781 | |||
| 297f373548 | |||
| 81f28da8e1 | |||
| d4bb687032 | |||
| f9bc5037f5 |
+6
-17
@@ -1,5 +1,6 @@
|
||||
sudo: false
|
||||
language: rust
|
||||
cache: cargo
|
||||
|
||||
# run builds for all the trains (and more)
|
||||
rust:
|
||||
@@ -8,21 +9,9 @@ rust:
|
||||
- beta
|
||||
- nightly
|
||||
|
||||
before_script:
|
||||
- pip install 'travis-cargo<0.2' --user
|
||||
- export PATH=$HOME/.local/bin:$PATH
|
||||
matrix:
|
||||
include:
|
||||
- rust: nightly
|
||||
env: CLIPPY=true
|
||||
|
||||
script:
|
||||
- (cd serde && travis-cargo build)
|
||||
- (cd serde && travis-cargo --only beta test)
|
||||
- (cd serde && travis-cargo --only nightly test -- --features unstable-testing)
|
||||
- (cd serde && travis-cargo build -- --no-default-features)
|
||||
- (cd serde && travis-cargo --only nightly build -- --no-default-features --features alloc)
|
||||
- (cd serde && travis-cargo --only nightly build -- --no-default-features --features collections)
|
||||
- (cd test_suite && travis-cargo --only beta test)
|
||||
- (cd test_suite/deps && travis-cargo --only nightly build && cd .. && travis-cargo --only nightly test -- --features unstable-testing)
|
||||
- (cd test_suite/no_std && travis-cargo --only nightly build)
|
||||
|
||||
env:
|
||||
global:
|
||||
- TRAVIS_CARGO_NIGHTLY_FEATURE=""
|
||||
script: ./travis.sh
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"serde",
|
||||
"serde_codegen_internals",
|
||||
"serde_derive",
|
||||
"serde_test",
|
||||
"test_suite",
|
||||
"test_suite/no_std",
|
||||
]
|
||||
+2
-5
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde"
|
||||
version = "0.9.3"
|
||||
version = "0.9.5"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "A generic serialization/deserialization framework"
|
||||
@@ -22,10 +22,7 @@ std = []
|
||||
unstable = []
|
||||
alloc = ["unstable"]
|
||||
collections = ["alloc"]
|
||||
unstable-testing = ["clippy", "unstable", "std"]
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "0.*", optional = true }
|
||||
unstable-testing = ["unstable", "std"]
|
||||
|
||||
[dev-dependencies]
|
||||
serde_derive = "0.9"
|
||||
|
||||
+75
-27
@@ -51,7 +51,9 @@ use bytes;
|
||||
|
||||
/// This represents all the possible errors that can occur using the `ValueDeserializer`.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Error(ErrorImpl);
|
||||
pub struct Error {
|
||||
err: ErrorImpl,
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
type ErrorImpl = Box<str>;
|
||||
@@ -61,19 +63,23 @@ type ErrorImpl = ();
|
||||
impl de::Error for Error {
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
fn custom<T: Display>(msg: T) -> Self {
|
||||
Error(msg.to_string().into_boxed_str())
|
||||
Error {
|
||||
err: msg.to_string().into_boxed_str(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "std", feature = "collections")))]
|
||||
fn custom<T: Display>(_msg: T) -> Self {
|
||||
Error(())
|
||||
Error {
|
||||
err: (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
formatter.write_str(&self.0)
|
||||
formatter.write_str(&self.err)
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "std", feature = "collections")))]
|
||||
@@ -85,7 +91,7 @@ impl Display for Error {
|
||||
impl error::Error for Error {
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
fn description(&self) -> &str {
|
||||
&self.0
|
||||
&self.err
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "std", feature = "collections")))]
|
||||
@@ -113,12 +119,16 @@ impl<E> ValueDeserializer<E> for ()
|
||||
type Deserializer = UnitDeserializer<E>;
|
||||
|
||||
fn into_deserializer(self) -> UnitDeserializer<E> {
|
||||
UnitDeserializer(PhantomData)
|
||||
UnitDeserializer {
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A helper deserializer that deserializes a `()`.
|
||||
pub struct UnitDeserializer<E>(PhantomData<E>);
|
||||
pub struct UnitDeserializer<E> {
|
||||
marker: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<E> de::Deserializer for UnitDeserializer<E>
|
||||
where E: de::Error
|
||||
@@ -149,7 +159,10 @@ impl<E> de::Deserializer for UnitDeserializer<E>
|
||||
macro_rules! primitive_deserializer {
|
||||
($ty:ty, $name:ident, $method:ident $($cast:tt)*) => {
|
||||
/// A helper deserializer that deserializes a number.
|
||||
pub struct $name<E>($ty, PhantomData<E>);
|
||||
pub struct $name<E> {
|
||||
value: $ty,
|
||||
marker: PhantomData<E>
|
||||
}
|
||||
|
||||
impl<E> ValueDeserializer<E> for $ty
|
||||
where E: de::Error,
|
||||
@@ -157,7 +170,10 @@ macro_rules! primitive_deserializer {
|
||||
type Deserializer = $name<E>;
|
||||
|
||||
fn into_deserializer(self) -> $name<E> {
|
||||
$name(self, PhantomData)
|
||||
$name {
|
||||
value: self,
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +191,7 @@ macro_rules! primitive_deserializer {
|
||||
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
visitor.$method(self.0 $($cast)*)
|
||||
visitor.$method(self.value $($cast)*)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +215,10 @@ primitive_deserializer!(char, CharDeserializer, visit_char);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// A helper deserializer that deserializes a `&str`.
|
||||
pub struct StrDeserializer<'a, E>(&'a str, PhantomData<E>);
|
||||
pub struct StrDeserializer<'a, E> {
|
||||
value: &'a str,
|
||||
marker: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<'a, E> ValueDeserializer<E> for &'a str
|
||||
where E: de::Error,
|
||||
@@ -207,7 +226,10 @@ impl<'a, E> ValueDeserializer<E> for &'a str
|
||||
type Deserializer = StrDeserializer<'a, E>;
|
||||
|
||||
fn into_deserializer(self) -> StrDeserializer<'a, E> {
|
||||
StrDeserializer(self, PhantomData)
|
||||
StrDeserializer {
|
||||
value: self,
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +241,7 @@ impl<'a, E> de::Deserializer for StrDeserializer<'a, E>
|
||||
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
visitor.visit_str(self.0)
|
||||
visitor.visit_str(self.value)
|
||||
}
|
||||
|
||||
fn deserialize_enum<V>(self,
|
||||
@@ -255,7 +277,10 @@ impl<'a, E> de::EnumVisitor for StrDeserializer<'a, E>
|
||||
|
||||
/// A helper deserializer that deserializes a `String`.
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
pub struct StringDeserializer<E>(String, PhantomData<E>);
|
||||
pub struct StringDeserializer<E> {
|
||||
value: String,
|
||||
marker: PhantomData<E>,
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
impl<E> ValueDeserializer<E> for String
|
||||
@@ -264,7 +289,10 @@ impl<E> ValueDeserializer<E> for String
|
||||
type Deserializer = StringDeserializer<E>;
|
||||
|
||||
fn into_deserializer(self) -> StringDeserializer<E> {
|
||||
StringDeserializer(self, PhantomData)
|
||||
StringDeserializer {
|
||||
value: self,
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +305,7 @@ impl<E> de::Deserializer for StringDeserializer<E>
|
||||
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
visitor.visit_string(self.0)
|
||||
visitor.visit_string(self.value)
|
||||
}
|
||||
|
||||
fn deserialize_enum<V>(self,
|
||||
@@ -314,7 +342,10 @@ impl<'a, E> de::EnumVisitor for StringDeserializer<E>
|
||||
|
||||
/// A helper deserializer that deserializes a `String`.
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
pub struct CowStrDeserializer<'a, E>(Cow<'a, str>, PhantomData<E>);
|
||||
pub struct CowStrDeserializer<'a, E> {
|
||||
value: Cow<'a, str>,
|
||||
marker: PhantomData<E>,
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
impl<'a, E> ValueDeserializer<E> for Cow<'a, str>
|
||||
@@ -323,7 +354,10 @@ impl<'a, E> ValueDeserializer<E> for Cow<'a, str>
|
||||
type Deserializer = CowStrDeserializer<'a, E>;
|
||||
|
||||
fn into_deserializer(self) -> CowStrDeserializer<'a, E> {
|
||||
CowStrDeserializer(self, PhantomData)
|
||||
CowStrDeserializer {
|
||||
value: self,
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +370,7 @@ impl<'a, E> de::Deserializer for CowStrDeserializer<'a, E>
|
||||
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
match self.0 {
|
||||
match self.value {
|
||||
Cow::Borrowed(string) => visitor.visit_str(string),
|
||||
Cow::Owned(string) => visitor.visit_string(string),
|
||||
}
|
||||
@@ -885,12 +919,18 @@ impl<'a, E> ValueDeserializer<E> for bytes::Bytes<'a>
|
||||
type Deserializer = BytesDeserializer<'a, E>;
|
||||
|
||||
fn into_deserializer(self) -> BytesDeserializer<'a, E> {
|
||||
BytesDeserializer(self.into(), PhantomData)
|
||||
BytesDeserializer {
|
||||
value: self.into(),
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A helper deserializer that deserializes a `&[u8]`.
|
||||
pub struct BytesDeserializer<'a, E>(&'a [u8], PhantomData<E>);
|
||||
pub struct BytesDeserializer<'a, E> {
|
||||
value: &'a [u8],
|
||||
marker: PhantomData<E>,
|
||||
}
|
||||
|
||||
impl<'a, E> de::Deserializer for BytesDeserializer<'a, E>
|
||||
where E: de::Error
|
||||
@@ -900,7 +940,7 @@ impl<'a, E> de::Deserializer for BytesDeserializer<'a, E>
|
||||
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
visitor.visit_bytes(self.0)
|
||||
visitor.visit_bytes(self.value)
|
||||
}
|
||||
|
||||
forward_to_deserialize! {
|
||||
@@ -919,13 +959,19 @@ impl<E> ValueDeserializer<E> for bytes::ByteBuf
|
||||
type Deserializer = ByteBufDeserializer<E>;
|
||||
|
||||
fn into_deserializer(self) -> Self::Deserializer {
|
||||
ByteBufDeserializer(self.into(), PhantomData)
|
||||
ByteBufDeserializer {
|
||||
value: self.into(),
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A helper deserializer that deserializes a `Vec<u8>`.
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
pub struct ByteBufDeserializer<E>(Vec<u8>, PhantomData<E>);
|
||||
pub struct ByteBufDeserializer<E> {
|
||||
value: Vec<u8>,
|
||||
marker: PhantomData<E>,
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "std", feature = "collections"))]
|
||||
impl<E> de::Deserializer for ByteBufDeserializer<E>
|
||||
@@ -936,7 +982,7 @@ impl<E> de::Deserializer for ByteBufDeserializer<E>
|
||||
fn deserialize<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
visitor.visit_byte_buf(self.0)
|
||||
visitor.visit_byte_buf(self.value)
|
||||
}
|
||||
|
||||
forward_to_deserialize! {
|
||||
@@ -952,10 +998,12 @@ mod private {
|
||||
use de::{self, Unexpected};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
pub struct UnitOnly<E>(PhantomData<E>);
|
||||
pub struct UnitOnly<E> {
|
||||
marker: PhantomData<E>,
|
||||
}
|
||||
|
||||
pub fn unit_only<T, E>(t: T) -> (T, UnitOnly<E>) {
|
||||
(t, UnitOnly(PhantomData))
|
||||
(t, UnitOnly { marker: PhantomData })
|
||||
}
|
||||
|
||||
impl<E> de::VariantVisitor for UnitOnly<E>
|
||||
|
||||
+1
-3
@@ -64,9 +64,7 @@
|
||||
#![cfg_attr(feature = "unstable", feature(nonzero, inclusive_range, zero_one))]
|
||||
#![cfg_attr(feature = "alloc", feature(alloc))]
|
||||
#![cfg_attr(feature = "collections", feature(collections, enumset))]
|
||||
#![cfg_attr(feature = "clippy", feature(plugin))]
|
||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||
#![cfg_attr(feature = "clippy", allow(linkedlist, type_complexity, doc_markdown))]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(linkedlist, type_complexity, doc_markdown))]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
#[cfg(feature = "collections")]
|
||||
|
||||
@@ -231,7 +231,7 @@ impl<'a, I> Serialize for Iterator<I>
|
||||
where S: Serializer,
|
||||
{
|
||||
// FIXME: use specialization to prevent invalidating the object in case of clonable iterators?
|
||||
let iter = match self.0.borrow_mut().take() {
|
||||
let iter = match self.data.borrow_mut().take() {
|
||||
Some(iter) => iter.into_iter(),
|
||||
None => return Err(Error::custom("Iterator used twice")),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
//! This module contains `Impossible` serializer and its implementations.
|
||||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use ser::{
|
||||
self,
|
||||
Serialize,
|
||||
SerializeSeq,
|
||||
SerializeTuple,
|
||||
SerializeTupleStruct,
|
||||
SerializeTupleVariant,
|
||||
SerializeMap,
|
||||
SerializeStruct,
|
||||
SerializeStructVariant,
|
||||
};
|
||||
|
||||
/// Helper type for implementing a `Serializer` that does not support
|
||||
/// serializing one of the compound types.
|
||||
///
|
||||
/// This type cannot be instantiated, but implements every one of the traits
|
||||
/// corresponding to the `Serializer` compound types: `SerializeSeq`,
|
||||
/// `SerializeTuple`, `SerializeTupleStruct`, `SerializeTupleVariant`,
|
||||
/// `SerializeMap`, `SerializeStruct`, and `SerializeStructVariant`.
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// impl Serializer for MySerializer {
|
||||
/// type Ok = ();
|
||||
/// type Error = Error;
|
||||
///
|
||||
/// type SerializeSeq = Impossible<(), Error>;
|
||||
/// /* other associated types */
|
||||
///
|
||||
/// /// This data format does not support serializing sequences.
|
||||
/// fn serialize_seq(self,
|
||||
/// len: Option<usize>)
|
||||
/// -> Result<Self::SerializeSeq, Error> {
|
||||
/// // Given Impossible cannot be instantiated, the only
|
||||
/// // thing we can do here is to return an error.
|
||||
/// Err(...)
|
||||
/// }
|
||||
///
|
||||
/// /* other Serializer methods */
|
||||
/// }
|
||||
/// ```
|
||||
pub struct Impossible<Ok, E> {
|
||||
void: Void,
|
||||
_marker: PhantomData<(Ok, E)>,
|
||||
}
|
||||
|
||||
enum Void {}
|
||||
|
||||
impl<Ok, E> SerializeSeq for Impossible<Ok, E>
|
||||
where E: ser::Error,
|
||||
{
|
||||
type Ok = Ok;
|
||||
type Error = E;
|
||||
|
||||
fn serialize_element<T: ?Sized + Serialize>(&mut self,
|
||||
_value: &T)
|
||||
-> Result<(), E> {
|
||||
match self.void {}
|
||||
}
|
||||
|
||||
fn end(self) -> Result<Ok, E> {
|
||||
match self.void {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Ok, E> SerializeTuple for Impossible<Ok, E>
|
||||
where E: ser::Error,
|
||||
{
|
||||
type Ok = Ok;
|
||||
type Error = E;
|
||||
|
||||
fn serialize_element<T: ?Sized + Serialize>(&mut self,
|
||||
_value: &T)
|
||||
-> Result<(), E> {
|
||||
match self.void {}
|
||||
}
|
||||
|
||||
fn end(self) -> Result<Ok, E> {
|
||||
match self.void {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Ok, E> SerializeTupleStruct for Impossible<Ok, E>
|
||||
where E: ser::Error,
|
||||
{
|
||||
type Ok = Ok;
|
||||
type Error = E;
|
||||
|
||||
fn serialize_field<T: ?Sized + Serialize>(&mut self,
|
||||
_value: &T)
|
||||
-> Result<(), E> {
|
||||
match self.void {}
|
||||
}
|
||||
|
||||
fn end(self) -> Result<Ok, E> {
|
||||
match self.void {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Ok, E> SerializeTupleVariant for Impossible<Ok, E>
|
||||
where E: ser::Error,
|
||||
{
|
||||
type Ok = Ok;
|
||||
type Error = E;
|
||||
|
||||
fn serialize_field<T: ?Sized + Serialize>(&mut self,
|
||||
_value: &T)
|
||||
-> Result<(), E> {
|
||||
match self.void {}
|
||||
}
|
||||
|
||||
fn end(self) -> Result<Ok, E> {
|
||||
match self.void {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Ok, E> SerializeMap for Impossible<Ok, E>
|
||||
where E: ser::Error,
|
||||
{
|
||||
type Ok = Ok;
|
||||
type Error = E;
|
||||
|
||||
fn serialize_key<T: ?Sized + Serialize>(&mut self,
|
||||
_key: &T)
|
||||
-> Result<(), E> {
|
||||
match self.void {}
|
||||
}
|
||||
|
||||
fn serialize_value<T: ?Sized + Serialize>(&mut self,
|
||||
_value: &T)
|
||||
-> Result<(), E> {
|
||||
match self.void {}
|
||||
}
|
||||
|
||||
fn end(self) -> Result<Ok, E> {
|
||||
match self.void {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Ok, E> SerializeStruct for Impossible<Ok, E>
|
||||
where E: ser::Error,
|
||||
{
|
||||
type Ok = Ok;
|
||||
type Error = E;
|
||||
|
||||
fn serialize_field<T: ?Sized + Serialize>(&mut self,
|
||||
_key: &'static str,
|
||||
_value: &T)
|
||||
-> Result<(), E> {
|
||||
match self.void {}
|
||||
}
|
||||
|
||||
fn end(self) -> Result<Ok, E> {
|
||||
match self.void {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Ok, E> SerializeStructVariant for Impossible<Ok, E>
|
||||
where E: ser::Error,
|
||||
{
|
||||
type Ok = Ok;
|
||||
type Error = E;
|
||||
|
||||
fn serialize_field<T: ?Sized + Serialize>(&mut self,
|
||||
_key: &'static str,
|
||||
_value: &T)
|
||||
-> Result<(), E> {
|
||||
match self.void {}
|
||||
}
|
||||
|
||||
fn end(self) -> Result<Ok, E> {
|
||||
match self.void {}
|
||||
}
|
||||
}
|
||||
+11
-3
@@ -104,6 +104,9 @@ use core::cell::RefCell;
|
||||
use core::fmt::Display;
|
||||
|
||||
mod impls;
|
||||
mod impossible;
|
||||
|
||||
pub use self::impossible::Impossible;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -802,9 +805,12 @@ pub trait SerializeStructVariant {
|
||||
/// of this with the `serde::ser::iterator` function every time you want to
|
||||
/// serialize an iterator.
|
||||
#[cfg(feature = "unstable")]
|
||||
pub struct Iterator<I>(RefCell<Option<I>>)
|
||||
pub struct Iterator<I>
|
||||
where <I as IntoIterator>::Item: Serialize,
|
||||
I: IntoIterator;
|
||||
I: IntoIterator
|
||||
{
|
||||
data: RefCell<Option<I>>,
|
||||
}
|
||||
|
||||
/// Create a wrapper type that can be passed to any function expecting a
|
||||
/// `Serialize` and will serialize the given iterator as a sequence.
|
||||
@@ -813,5 +819,7 @@ pub fn iterator<I>(iter: I) -> Iterator<I>
|
||||
where <I as IntoIterator>::Item: Serialize,
|
||||
I: IntoIterator
|
||||
{
|
||||
Iterator(RefCell::new(Some(iter)))
|
||||
Iterator {
|
||||
data: RefCell::new(Some(iter)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_codegen_internals"
|
||||
version = "0.12.0"
|
||||
version = "0.12.1"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "AST representation used by Serde codegen. Unstable."
|
||||
@@ -10,11 +10,7 @@ documentation = "https://docs.serde.rs/serde_codegen_internals/"
|
||||
keywords = ["serde", "serialization"]
|
||||
include = ["Cargo.toml", "src/**/*.rs"]
|
||||
|
||||
[features]
|
||||
unstable-testing = ["clippy"]
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "0.*", optional = true }
|
||||
syn = "0.11"
|
||||
|
||||
[badges]
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||
#![cfg_attr(feature = "clippy", feature(plugin))]
|
||||
|
||||
extern crate syn;
|
||||
|
||||
pub mod ast;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_derive"
|
||||
version = "0.9.3"
|
||||
version = "0.9.5"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||
@@ -12,7 +12,6 @@ include = ["Cargo.toml", "src/**/*.rs"]
|
||||
|
||||
[features]
|
||||
unstable = []
|
||||
unstable-testing = ["clippy", "serde_codegen_internals/unstable-testing"]
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "serde-rs/serde" }
|
||||
@@ -22,7 +21,6 @@ name = "serde_derive"
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "0.*", optional = true }
|
||||
quote = "0.3.8"
|
||||
serde_codegen_internals = { version = "=0.12.0", default-features = false, path = "../serde_codegen_internals" }
|
||||
serde_codegen_internals = { version = "=0.12.1", default-features = false, path = "../serde_codegen_internals" }
|
||||
syn = { version = "0.11", features = ["aster", "visit"] }
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||
#![cfg_attr(feature = "clippy", feature(plugin))]
|
||||
#![cfg_attr(feature = "clippy", allow(too_many_arguments))]
|
||||
#![cfg_attr(feature = "clippy", allow(used_underscore_binding))]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(used_underscore_binding))]
|
||||
|
||||
// The `quote!` macro requires deep recursion.
|
||||
#![recursion_limit = "192"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde_test"
|
||||
version = "0.9.3"
|
||||
version = "0.9.5"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||
@@ -11,11 +11,7 @@ readme = "../README.md"
|
||||
keywords = ["serde", "serialization"]
|
||||
include = ["Cargo.toml", "src/**/*.rs"]
|
||||
|
||||
[features]
|
||||
unstable-testing = ["clippy"]
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "0.*", optional = true }
|
||||
serde = { version = "0.9", path = "../serde" }
|
||||
|
||||
[badges]
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
#![cfg_attr(feature = "clippy", feature(plugin))]
|
||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||
|
||||
extern crate serde;
|
||||
|
||||
mod assert;
|
||||
|
||||
@@ -13,11 +13,8 @@ publish = false
|
||||
|
||||
[features]
|
||||
unstable-testing = [
|
||||
"clippy",
|
||||
"compiletest_rs",
|
||||
"serde/unstable-testing",
|
||||
"serde_derive/unstable-testing",
|
||||
"serde_test/unstable-testing",
|
||||
]
|
||||
|
||||
[dev-dependencies]
|
||||
@@ -28,7 +25,6 @@ serde_derive = { path = "../serde_derive" }
|
||||
serde_test = { path = "../serde_test" }
|
||||
|
||||
[dependencies]
|
||||
clippy = { version = "0.*", optional = true }
|
||||
compiletest_rs = { version = "0.2", optional = true }
|
||||
|
||||
[[test]]
|
||||
|
||||
@@ -4,6 +4,8 @@ version = "0.0.0"
|
||||
authors = ["David Tolnay <dtolnay@gmail.com>"]
|
||||
publish = false
|
||||
|
||||
[workspace]
|
||||
|
||||
[dependencies]
|
||||
serde = { path = "../../serde" }
|
||||
serde_derive = { path = "../../serde_derive" }
|
||||
|
||||
@@ -21,7 +21,9 @@ pub extern fn rust_eh_unwind_resume() {}
|
||||
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
|
||||
_file: &'static str,
|
||||
_line: u32) -> ! {
|
||||
loop {}
|
||||
unsafe {
|
||||
libc::abort()
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
#![cfg_attr(feature = "clippy", feature(plugin))]
|
||||
#![cfg_attr(feature = "clippy", plugin(clippy))]
|
||||
|
||||
#![cfg_attr(feature = "unstable-testing", feature(test, non_ascii_idents))]
|
||||
|
||||
#[cfg(feature = "unstable-testing")]
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
channel() {
|
||||
if [ -n "${TRAVIS}" ]; then
|
||||
if [ "${TRAVIS_RUST_VERSION}" = "${CHANNEL}" ]; then
|
||||
pwd
|
||||
(set -x; cargo "$@")
|
||||
fi
|
||||
else
|
||||
pwd
|
||||
(set -x; cargo "+${CHANNEL}" "$@")
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -n "${CLIPPY}" ]; then
|
||||
# cached installation will not work on a later nightly
|
||||
if [ -n "${TRAVIS}" ] && ! cargo install clippy --debug --force; then
|
||||
echo "COULD NOT COMPILE CLIPPY, IGNORING CLIPPY TESTS"
|
||||
exit
|
||||
fi
|
||||
|
||||
cd "$DIR/serde"
|
||||
cargo clippy --features unstable-testing -- -Dclippy
|
||||
|
||||
cd "$DIR/serde_derive"
|
||||
cargo clippy --features unstable-testing -- -Dclippy
|
||||
|
||||
cd "$DIR/test_suite"
|
||||
cargo clippy --features unstable-testing -- -Dclippy
|
||||
|
||||
cd "$DIR/test_suite/no_std"
|
||||
cargo clippy -- -Dclippy
|
||||
else
|
||||
CHANNEL=nightly
|
||||
cargo clean
|
||||
cd "$DIR/serde"
|
||||
channel build
|
||||
channel build --no-default-features
|
||||
channel build --no-default-features --features alloc
|
||||
channel build --no-default-features --features collections
|
||||
channel test --features unstable-testing
|
||||
cd "$DIR/test_suite/deps"
|
||||
channel build
|
||||
cd "$DIR/test_suite"
|
||||
channel test --features unstable-testing
|
||||
cd "$DIR/test_suite/no_std"
|
||||
channel build
|
||||
|
||||
CHANNEL=beta
|
||||
cargo clean
|
||||
cd "$DIR/serde"
|
||||
channel build
|
||||
cd "$DIR/test_suite"
|
||||
channel test
|
||||
|
||||
CHANNEL=stable
|
||||
cargo clean
|
||||
cd "$DIR/serde"
|
||||
channel build
|
||||
channel build --no-default-features
|
||||
|
||||
CHANNEL=1.13.0
|
||||
cargo clean
|
||||
cd "$DIR/serde"
|
||||
channel build
|
||||
channel build --no-default-features
|
||||
fi
|
||||
Reference in New Issue
Block a user