Skip to content

Instantly share code, notes, and snippets.

@jdiez17
Created December 27, 2016 20:39
Show Gist options
  • Save jdiez17/b26516988eba2b4e89b40df48fe97478 to your computer and use it in GitHub Desktop.
Save jdiez17/b26516988eba2b4e89b40df48fe97478 to your computer and use it in GitHub Desktop.
// ...
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[..]));
}
}
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