Rename named_* to use {enum,struct,unit}_*
This better reflects how they're used.
This commit is contained in:
parent
d30cf07254
commit
10f23dddfe
@ -187,7 +187,7 @@ impl serde::Serialize for Point {
|
|||||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||||
where S: serde::Serializer
|
where S: serde::Serializer
|
||||||
{
|
{
|
||||||
serializer.visit_named_map("Point", PointMapVisitor {
|
serializer.visit_struct("Point", PointMapVisitor {
|
||||||
value: self,
|
value: self,
|
||||||
state: 0,
|
state: 0,
|
||||||
})
|
})
|
||||||
@ -383,7 +383,7 @@ impl serde::Deserialize for Point {
|
|||||||
fn deserialize<D>(deserializer: &mut D) -> Result<Point, D::Error>
|
fn deserialize<D>(deserializer: &mut D) -> Result<Point, D::Error>
|
||||||
where D: serde::de::Deserializer
|
where D: serde::de::Deserializer
|
||||||
{
|
{
|
||||||
deserializer.visit_named_map("Point", PointVisitor)
|
deserializer.visit_struct("Point", PointVisitor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,25 +211,25 @@ pub trait Deserializer {
|
|||||||
/// This method hints that the `Deserialize` type is expecting a named unit. This allows
|
/// This method hints that the `Deserialize` type is expecting a named unit. This allows
|
||||||
/// deserializers to a named unit that aren't tagged as a named unit.
|
/// deserializers to a named unit that aren't tagged as a named unit.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_named_unit<V>(&mut self, _name: &str, visitor: V) -> Result<V::Value, Self::Error>
|
fn visit_unit_struct<V>(&mut self, _name: &str, visitor: V) -> Result<V::Value, Self::Error>
|
||||||
where V: Visitor,
|
where V: Visitor,
|
||||||
{
|
{
|
||||||
self.visit(visitor)
|
self.visit(visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This method hints that the `Deserialize` type is expecting a named sequence.
|
/// This method hints that the `Deserialize` type is expecting a tuple struct. This allows
|
||||||
/// This allows deserializers to parse sequences that aren't tagged as sequences.
|
/// deserializers to parse sequences that aren't tagged as sequences.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_named_seq<V>(&mut self, _name: &str, visitor: V) -> Result<V::Value, Self::Error>
|
fn visit_tuple_struct<V>(&mut self, _name: &str, visitor: V) -> Result<V::Value, Self::Error>
|
||||||
where V: Visitor,
|
where V: Visitor,
|
||||||
{
|
{
|
||||||
self.visit_seq(visitor)
|
self.visit_seq(visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This method hints that the `Deserialize` type is expecting a named map. This allows
|
/// This method hints that the `Deserialize` type is expecting a struct. This allows
|
||||||
/// deserializers to parse sequences that aren't tagged as maps.
|
/// deserializers to parse sequences that aren't tagged as maps.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_named_map<V>(&mut self, _name: &str, visitor: V) -> Result<V::Value, Self::Error>
|
fn visit_struct<V>(&mut self, _name: &str, visitor: V) -> Result<V::Value, Self::Error>
|
||||||
where V: Visitor,
|
where V: Visitor,
|
||||||
{
|
{
|
||||||
self.visit_map(visitor)
|
self.visit_map(visitor)
|
||||||
@ -386,7 +386,7 @@ pub trait Visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_named_unit<E>(&mut self, _name: &str) -> Result<Self::Value, E>
|
fn visit_unit_struct<E>(&mut self, _name: &str) -> Result<Self::Value, E>
|
||||||
where E: Error,
|
where E: Error,
|
||||||
{
|
{
|
||||||
self.visit_unit()
|
self.visit_unit()
|
||||||
|
@ -113,7 +113,7 @@ pub trait Serializer {
|
|||||||
fn visit_unit(&mut self) -> Result<(), Self::Error>;
|
fn visit_unit(&mut self) -> Result<(), Self::Error>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_named_unit(&mut self, _name: &str) -> Result<(), Self::Error> {
|
fn visit_unit_struct(&mut self, _name: &str) -> Result<(), Self::Error> {
|
||||||
self.visit_unit()
|
self.visit_unit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +150,7 @@ pub trait Serializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_named_seq<V>(&mut self,
|
fn visit_tuple_struct<V>(&mut self,
|
||||||
_name: &'static str,
|
_name: &'static str,
|
||||||
visitor: V) -> Result<(), Self::Error>
|
visitor: V) -> Result<(), Self::Error>
|
||||||
where V: SeqVisitor,
|
where V: SeqVisitor,
|
||||||
@ -159,7 +159,7 @@ pub trait Serializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_named_seq_elt<T>(&mut self, value: T) -> Result<(), Self::Error>
|
fn visit_tuple_struct_elt<T>(&mut self, value: T) -> Result<(), Self::Error>
|
||||||
where T: Serialize
|
where T: Serialize
|
||||||
{
|
{
|
||||||
self.visit_tuple_elt(value)
|
self.visit_tuple_elt(value)
|
||||||
@ -172,14 +172,14 @@ pub trait Serializer {
|
|||||||
visitor: V) -> Result<(), Self::Error>
|
visitor: V) -> Result<(), Self::Error>
|
||||||
where V: SeqVisitor,
|
where V: SeqVisitor,
|
||||||
{
|
{
|
||||||
self.visit_named_seq(variant, visitor)
|
self.visit_tuple_struct(variant, visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_enum_seq_elt<T>(&mut self, value: T) -> Result<(), Self::Error>
|
fn visit_enum_seq_elt<T>(&mut self, value: T) -> Result<(), Self::Error>
|
||||||
where T: Serialize
|
where T: Serialize
|
||||||
{
|
{
|
||||||
self.visit_named_seq_elt(value)
|
self.visit_tuple_struct_elt(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_map<V>(&mut self, visitor: V) -> Result<(), Self::Error>
|
fn visit_map<V>(&mut self, visitor: V) -> Result<(), Self::Error>
|
||||||
@ -190,7 +190,7 @@ pub trait Serializer {
|
|||||||
V: Serialize;
|
V: Serialize;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_named_map<V>(&mut self,
|
fn visit_struct<V>(&mut self,
|
||||||
_name: &'static str,
|
_name: &'static str,
|
||||||
visitor: V) -> Result<(), Self::Error>
|
visitor: V) -> Result<(), Self::Error>
|
||||||
where V: MapVisitor,
|
where V: MapVisitor,
|
||||||
@ -199,7 +199,7 @@ pub trait Serializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn visit_named_map_elt<K, V>(&mut self, key: K, value: V) -> Result<(), Self::Error>
|
fn visit_struct_elt<K, V>(&mut self, key: K, value: V) -> Result<(), Self::Error>
|
||||||
where K: Serialize,
|
where K: Serialize,
|
||||||
V: Serialize,
|
V: Serialize,
|
||||||
{
|
{
|
||||||
@ -213,7 +213,7 @@ pub trait Serializer {
|
|||||||
visitor: V) -> Result<(), Self::Error>
|
visitor: V) -> Result<(), Self::Error>
|
||||||
where V: MapVisitor,
|
where V: MapVisitor,
|
||||||
{
|
{
|
||||||
self.visit_named_map(variant, visitor)
|
self.visit_struct(variant, visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -221,7 +221,7 @@ pub trait Serializer {
|
|||||||
where K: Serialize,
|
where K: Serialize,
|
||||||
V: Serialize,
|
V: Serialize,
|
||||||
{
|
{
|
||||||
self.visit_named_map_elt(key, value)
|
self.visit_struct_elt(key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specify a format string for the serializer.
|
/// Specify a format string for the serializer.
|
||||||
|
@ -260,7 +260,7 @@ fn deserialize_unit_struct(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializer.visit_named_unit($type_name, __Visitor)
|
deserializer.visit_unit_struct($type_name, __Visitor)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ fn deserialize_tuple_struct(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializer.visit_named_seq($type_name, $visitor_expr)
|
deserializer.visit_tuple_struct($type_name, $visitor_expr)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ fn deserialize_struct(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deserializer.visit_named_map($type_name, $visitor_expr)
|
deserializer.visit_struct($type_name, $visitor_expr)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ fn serialize_unit_struct(
|
|||||||
) -> P<ast::Expr> {
|
) -> P<ast::Expr> {
|
||||||
let type_name = builder.expr().str(type_ident);
|
let type_name = builder.expr().str(type_ident);
|
||||||
|
|
||||||
quote_expr!(cx, serializer.visit_named_unit($type_name))
|
quote_expr!(cx, serializer.visit_unit_struct($type_name))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_tuple_struct(
|
fn serialize_tuple_struct(
|
||||||
@ -194,7 +194,7 @@ fn serialize_tuple_struct(
|
|||||||
quote_expr!(cx, {
|
quote_expr!(cx, {
|
||||||
$visitor_struct
|
$visitor_struct
|
||||||
$visitor_impl
|
$visitor_impl
|
||||||
serializer.visit_named_seq($type_name, Visitor {
|
serializer.visit_tuple_struct($type_name, Visitor {
|
||||||
value: self,
|
value: self,
|
||||||
state: 0,
|
state: 0,
|
||||||
_structure_ty: ::std::marker::PhantomData,
|
_structure_ty: ::std::marker::PhantomData,
|
||||||
@ -226,7 +226,7 @@ fn serialize_struct(
|
|||||||
quote_expr!(cx, {
|
quote_expr!(cx, {
|
||||||
$visitor_struct
|
$visitor_struct
|
||||||
$visitor_impl
|
$visitor_impl
|
||||||
serializer.visit_named_map($type_name, Visitor {
|
serializer.visit_struct($type_name, Visitor {
|
||||||
value: self,
|
value: self,
|
||||||
state: 0,
|
state: 0,
|
||||||
_structure_ty: ::std::marker::PhantomData,
|
_structure_ty: ::std::marker::PhantomData,
|
||||||
@ -476,7 +476,7 @@ fn serialize_tuple_struct_visitor(
|
|||||||
quote_arm!(cx,
|
quote_arm!(cx,
|
||||||
$i => {
|
$i => {
|
||||||
self.state += 1;
|
self.state += 1;
|
||||||
let v = try!(serializer.visit_named_seq_elt(&$expr));
|
let v = try!(serializer.visit_tuple_struct_elt(&$expr));
|
||||||
Ok(Some(v))
|
Ok(Some(v))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -559,7 +559,7 @@ fn serialize_struct_visitor<I>(
|
|||||||
Ok(
|
Ok(
|
||||||
Some(
|
Some(
|
||||||
try!(
|
try!(
|
||||||
serializer.visit_named_map_elt(
|
serializer.visit_struct_elt(
|
||||||
$key_expr,
|
$key_expr,
|
||||||
$value_expr,
|
$value_expr,
|
||||||
)
|
)
|
||||||
|
@ -398,7 +398,7 @@ mod deserializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_named_map<V>(&mut self, name: &str, mut visitor: V) -> Result<V::Value, Error>
|
fn visit_struct<V>(&mut self, name: &str, mut visitor: V) -> Result<V::Value, Error>
|
||||||
where V: de::Visitor,
|
where V: de::Visitor,
|
||||||
{
|
{
|
||||||
match self.stack.pop() {
|
match self.stack.pop() {
|
||||||
|
@ -161,7 +161,7 @@ impl Deserializer for TokenDeserializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_named_unit<V>(&mut self, name: &str, visitor: V) -> Result<V::Value, Error>
|
fn visit_unit_struct<V>(&mut self, name: &str, visitor: V) -> Result<V::Value, Error>
|
||||||
where V: de::Visitor,
|
where V: de::Visitor,
|
||||||
{
|
{
|
||||||
match self.tokens.peek() {
|
match self.tokens.peek() {
|
||||||
@ -178,7 +178,7 @@ impl Deserializer for TokenDeserializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_named_seq<V>(&mut self, name: &str, visitor: V) -> Result<V::Value, Error>
|
fn visit_tuple_struct<V>(&mut self, name: &str, visitor: V) -> Result<V::Value, Error>
|
||||||
where V: de::Visitor,
|
where V: de::Visitor,
|
||||||
{
|
{
|
||||||
match self.tokens.peek() {
|
match self.tokens.peek() {
|
||||||
@ -195,7 +195,7 @@ impl Deserializer for TokenDeserializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_named_map<V>(&mut self, name: &str, visitor: V) -> Result<V::Value, Error>
|
fn visit_struct<V>(&mut self, name: &str, visitor: V) -> Result<V::Value, Error>
|
||||||
where V: de::Visitor,
|
where V: de::Visitor,
|
||||||
{
|
{
|
||||||
match self.tokens.peek() {
|
match self.tokens.peek() {
|
||||||
@ -334,13 +334,13 @@ impl<'a> de::VariantVisitor for TokenDeserializerVariantVisitor<'a> {
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Debug, Deserialize)]
|
#[derive(Copy, Clone, PartialEq, Debug, Deserialize)]
|
||||||
struct NamedUnit;
|
struct UnitStruct;
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Deserialize)]
|
#[derive(PartialEq, Debug, Deserialize)]
|
||||||
struct NamedSeq(i32, i32, i32);
|
struct TupleStruct(i32, i32, i32);
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Deserialize)]
|
#[derive(PartialEq, Debug, Deserialize)]
|
||||||
struct NamedMap {
|
struct Struct {
|
||||||
a: i32,
|
a: i32,
|
||||||
b: i32,
|
b: i32,
|
||||||
c: i32,
|
c: i32,
|
||||||
@ -498,19 +498,19 @@ declare_tests! {
|
|||||||
Token::SeqEnd,
|
Token::SeqEnd,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
test_named_unit {
|
test_unit_struct {
|
||||||
NamedUnit => vec![Token::Unit],
|
UnitStruct => vec![Token::Unit],
|
||||||
NamedUnit => vec![
|
UnitStruct => vec![
|
||||||
Token::Name("NamedUnit"),
|
Token::Name("UnitStruct"),
|
||||||
Token::Unit,
|
Token::Unit,
|
||||||
],
|
],
|
||||||
NamedUnit => vec![
|
UnitStruct => vec![
|
||||||
Token::SeqStart(0),
|
Token::SeqStart(0),
|
||||||
Token::SeqEnd,
|
Token::SeqEnd,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
test_named_seq {
|
test_tuple_struct {
|
||||||
NamedSeq(1, 2, 3) => vec![
|
TupleStruct(1, 2, 3) => vec![
|
||||||
Token::SeqStart(3),
|
Token::SeqStart(3),
|
||||||
Token::SeqSep,
|
Token::SeqSep,
|
||||||
Token::I32(1),
|
Token::I32(1),
|
||||||
@ -522,8 +522,8 @@ declare_tests! {
|
|||||||
Token::I32(3),
|
Token::I32(3),
|
||||||
Token::SeqEnd,
|
Token::SeqEnd,
|
||||||
],
|
],
|
||||||
NamedSeq(1, 2, 3) => vec![
|
TupleStruct(1, 2, 3) => vec![
|
||||||
Token::Name("NamedSeq"),
|
Token::Name("TupleStruct"),
|
||||||
Token::SeqStart(3),
|
Token::SeqStart(3),
|
||||||
Token::SeqSep,
|
Token::SeqSep,
|
||||||
Token::I32(1),
|
Token::I32(1),
|
||||||
@ -818,8 +818,8 @@ declare_tests! {
|
|||||||
Token::MapEnd,
|
Token::MapEnd,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
test_named_map {
|
test_struct {
|
||||||
NamedMap { a: 1, b: 2, c: 3 } => vec![
|
Struct { a: 1, b: 2, c: 3 } => vec![
|
||||||
Token::MapStart(3),
|
Token::MapStart(3),
|
||||||
Token::MapSep,
|
Token::MapSep,
|
||||||
Token::Str("a"),
|
Token::Str("a"),
|
||||||
@ -834,8 +834,8 @@ declare_tests! {
|
|||||||
Token::I32(3),
|
Token::I32(3),
|
||||||
Token::MapEnd,
|
Token::MapEnd,
|
||||||
],
|
],
|
||||||
NamedMap { a: 1, b: 2, c: 3 } => vec![
|
Struct { a: 1, b: 2, c: 3 } => vec![
|
||||||
Token::Name("NamedMap"),
|
Token::Name("Struct"),
|
||||||
Token::MapStart(3),
|
Token::MapStart(3),
|
||||||
Token::MapSep,
|
Token::MapSep,
|
||||||
Token::Str("a"),
|
Token::Str("a"),
|
||||||
|
@ -24,17 +24,17 @@ pub enum Token<'a> {
|
|||||||
Option(bool),
|
Option(bool),
|
||||||
|
|
||||||
Unit,
|
Unit,
|
||||||
NamedUnit(&'a str),
|
UnitStruct(&'a str),
|
||||||
EnumUnit(&'a str, &'a str),
|
EnumUnit(&'a str, &'a str),
|
||||||
|
|
||||||
SeqStart(Option<usize>),
|
SeqStart(Option<usize>),
|
||||||
NamedSeqStart(&'a str, Option<usize>),
|
TupleStructStart(&'a str, Option<usize>),
|
||||||
EnumSeqStart(&'a str, &'a str, Option<usize>),
|
EnumSeqStart(&'a str, &'a str, Option<usize>),
|
||||||
SeqSep,
|
SeqSep,
|
||||||
SeqEnd,
|
SeqEnd,
|
||||||
|
|
||||||
MapStart(Option<usize>),
|
MapStart(Option<usize>),
|
||||||
NamedMapStart(&'a str, Option<usize>),
|
StructStart(&'a str, Option<usize>),
|
||||||
EnumMapStart(&'a str, &'a str, Option<usize>),
|
EnumMapStart(&'a str, &'a str, Option<usize>),
|
||||||
MapSep,
|
MapSep,
|
||||||
MapEnd,
|
MapEnd,
|
||||||
@ -80,8 +80,8 @@ impl<'a> Serializer for AssertSerializer<'a> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_named_unit(&mut self, name: &str) -> Result<(), ()> {
|
fn visit_unit_struct(&mut self, name: &str) -> Result<(), ()> {
|
||||||
assert_eq!(self.iter.next().unwrap(), Token::NamedUnit(name));
|
assert_eq!(self.iter.next().unwrap(), Token::UnitStruct(name));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,12 +188,12 @@ impl<'a> Serializer for AssertSerializer<'a> {
|
|||||||
self.visit_sequence(visitor)
|
self.visit_sequence(visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_named_seq<V>(&mut self, name: &str, visitor: V) -> Result<(), ()>
|
fn visit_tuple_struct<V>(&mut self, name: &str, visitor: V) -> Result<(), ()>
|
||||||
where V: SeqVisitor
|
where V: SeqVisitor
|
||||||
{
|
{
|
||||||
let len = visitor.len();
|
let len = visitor.len();
|
||||||
|
|
||||||
assert_eq!(self.iter.next().unwrap(), Token::NamedSeqStart(name, len));
|
assert_eq!(self.iter.next().unwrap(), Token::TupleStructStart(name, len));
|
||||||
|
|
||||||
self.visit_sequence(visitor)
|
self.visit_sequence(visitor)
|
||||||
}
|
}
|
||||||
@ -228,12 +228,12 @@ impl<'a> Serializer for AssertSerializer<'a> {
|
|||||||
self.visit_mapping(visitor)
|
self.visit_mapping(visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_named_map<V>(&mut self, name: &str, visitor: V) -> Result<(), ()>
|
fn visit_struct<V>(&mut self, name: &str, visitor: V) -> Result<(), ()>
|
||||||
where V: MapVisitor
|
where V: MapVisitor
|
||||||
{
|
{
|
||||||
let len = visitor.len();
|
let len = visitor.len();
|
||||||
|
|
||||||
assert_eq!(self.iter.next().unwrap(), Token::NamedMapStart(name, len));
|
assert_eq!(self.iter.next().unwrap(), Token::StructStart(name, len));
|
||||||
|
|
||||||
self.visit_mapping(visitor)
|
self.visit_mapping(visitor)
|
||||||
}
|
}
|
||||||
@ -262,13 +262,13 @@ impl<'a> Serializer for AssertSerializer<'a> {
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct NamedUnit;
|
struct UnitStruct;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct NamedSeq(i32, i32, i32);
|
struct TupleStruct(i32, i32, i32);
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct NamedMap {
|
struct Struct {
|
||||||
a: i32,
|
a: i32,
|
||||||
b: i32,
|
b: i32,
|
||||||
c: i32,
|
c: i32,
|
||||||
@ -480,12 +480,12 @@ declare_tests! {
|
|||||||
Token::MapEnd,
|
Token::MapEnd,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
test_named_unit {
|
test_unit_struct {
|
||||||
NamedUnit => vec![Token::NamedUnit("NamedUnit")],
|
UnitStruct => vec![Token::UnitStruct("UnitStruct")],
|
||||||
}
|
}
|
||||||
test_named_seq {
|
test_tuple_struct {
|
||||||
NamedSeq(1, 2, 3) => vec![
|
TupleStruct(1, 2, 3) => vec![
|
||||||
Token::NamedSeqStart("NamedSeq", Some(3)),
|
Token::TupleStructStart("TupleStruct", Some(3)),
|
||||||
Token::SeqSep,
|
Token::SeqSep,
|
||||||
Token::I32(1),
|
Token::I32(1),
|
||||||
|
|
||||||
@ -497,9 +497,9 @@ declare_tests! {
|
|||||||
Token::SeqEnd,
|
Token::SeqEnd,
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
test_named_map {
|
test_struct {
|
||||||
NamedMap { a: 1, b: 2, c: 3 } => vec![
|
Struct { a: 1, b: 2, c: 3 } => vec![
|
||||||
Token::NamedMapStart("NamedMap", Some(3)),
|
Token::StructStart("Struct", Some(3)),
|
||||||
Token::MapSep,
|
Token::MapSep,
|
||||||
Token::Str("a"),
|
Token::Str("a"),
|
||||||
Token::I32(1),
|
Token::I32(1),
|
||||||
|
Loading…
Reference in New Issue
Block a user