De/serialize for HashMap<K, V, S>

This commit is contained in:
David Tolnay
2016-06-11 00:43:02 -07:00
parent 84a573c926
commit 46a1860601
6 changed files with 62 additions and 31 deletions
+17 -1
View File
@@ -1,10 +1,13 @@
use std::collections::BTreeMap;
use std::collections::{BTreeMap, HashMap};
use std::net;
use std::path::{Path, PathBuf};
use std::str;
use token::{self, Token};
extern crate fnv;
use self::fnv::FnvHasher;
//////////////////////////////////////////////////////////////////////////
#[derive(Serialize)]
@@ -204,6 +207,19 @@ declare_ser_tests! {
Token::MapEnd,
],
}
test_hashmap {
hashmap![FnvHasher @ 1 => 2, 3 => 4] => &[
Token::MapStart(Some(2)),
Token::MapSep,
Token::I32(1),
Token::I32(2),
Token::MapSep,
Token::I32(3),
Token::I32(4),
Token::MapEnd,
],
}
test_unit_struct {
UnitStruct => &[Token::UnitStruct("UnitStruct")],
}