We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My cargo.toml
[dependencies] serde = { version = "1.0", features = ["derive"] } serde_bytes = "0.10.0" serde_bencode = { path = "serde-bencode" }
Version of rustc
rustc 1.35.0 (3c235d560 2019-05-20)
And my code
use serde::{Deserialize, Serialize}; use serde_bencode::de; use serde_bencode::ser; use std::str; #[derive(Debug, Deserialize, Serialize)] struct Node(String, i64); fn main() { let nodes: Vec<Node> = vec![ Node("aaa".to_owned(), 5665), Node("bbb".to_owned(), 5665), Node("ccc".to_owned(), 5665), ]; let buffer: Vec<u8> = match ser::to_bytes(&nodes) { Ok(s) => s, Err(e) => panic!(e), }; println!("{}", str::from_utf8(&buffer).unwrap()); match de::from_bytes::<Vec<Node>>(&buffer) { Ok(t) => { // println!("{}", t.len()); println!("{:?}", t); } Err(e) => println!("ERROR: {:?}", e), }; }
And just got
ll3:aaai5665eel3:bbbi5665eel3:ccci5665eee [Node("aaa", 5665)]
By the way, I am just a rust noob. Maybe I just made some mistake?
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
My cargo.toml
Version of rustc
And my code
And just got
By the way, I am just a rust noob. Maybe I just made some mistake?
The text was updated successfully, but these errors were encountered: