Created
December 27, 2016 20:39
-
-
Save jdiez17/b26516988eba2b4e89b40df48fe97478 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
type SizeMap = HashMap<Vec<String>, u32>; | |
fn document_size(bytes: &[u8]) -> SizeMap { | |
// ... | |
} | |
#[cfg(test)] | |
mod tests { | |
use super::*; | |
#[test] | |
fn test_sizes() { | |
let doc: Vec<u8> = vec![ | |
0x0b, 0x00, 0x00, 0x00, // Document size | |
0x08, 0x66, 0x6f, 0x6f, 0x00, 0x01, // "foo" => true | |
0x00 // Document end | |
]; | |
let mut expct = SizeMap::new(); | |
expct.insert(vec!["root"], 0x0b); | |
expct.insert(vec!["root", "foo"], 0x01); | |
assert_eq!(expct, document_size(&doc[..])); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0308]: mismatched types | |
--> src/bson.rs:36:27 | |
| | |
36 | expct.insert(vec!["root"], 0x0b); | |
| ^^^^^^ expected struct `std::string::String`, found reference | |
| | |
= note: expected type `_` | |
= note: found type `&'static str` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment