bufwriter/
main.rs

1use bencodex::{BDict, BNode};
2use std::{env, fs::File};
3
4fn main() {
5    let mut dict = BDict::new();
6    dict.insert("bar".to_string(), "spam".into());
7    dict.insert("foo".to_string(), 42.into());
8
9    let bnode: BNode = dict.into();
10
11    let mut file = File::create(
12        env::current_dir()
13            .unwrap()
14            .join("examples")
15            .join("bufwriter")
16            .join("bufwriter-test.torrent"),
17    )
18    .unwrap();
19    bnode.serialize(&mut file).unwrap();
20}