File: parse.rs

package info (click to toggle)
rust-deser-hjson 2.2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 252 kB
  • sloc: makefile: 4
file content (69 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// use {
//     deser_hjson::from_str,
//     serde:: Deserialize,
//     glassbench::*,
// };

// static GIFTS: &[&str] = &[
//     "{gift:null}",
//     "{gift:false}",
//     "{gift: true}",
//     "{gift:'bar'}",
//     r#"{gift:"bar"}"#,
//     "{gift:42}",
//     "{gift:42457811247}",
//     "{gift:-42}",
//     r#"{gift: "abcㅈ"}"#,
//     "{gift:[15, -50]}",
//     "{gift:[\"abc\"]}",
//     r#"{gift:["abc", "another string"]}"#,
//     r#" {
//         gift: [
//             "abc",
//             "another string"
//             and a third one (unquoted)
//         ]
//     }"#,
//     "{gift:''}",
// ];

// #[derive(Deserialize, PartialEq, Debug)]
// #[serde(untagged)]
// enum Guess {
//     Bool(bool),
//     U8(u8),
//     I8(i8),
//     U16(u16),
//     I16(i16),
//     U32(u32),
//     I32(i32),
//     U64(u64),
//     I64(i64),
//     F64(f64),
//     Char(char),
//     String(Option<String>),
//     U16Array(Vec<u16>),
//     I16Array(Vec<i16>),
//     StrArray(Vec<String>),
// }
// #[derive(Deserialize, PartialEq, Debug)]
// struct WrappedGuess {
//     gift: Guess,
// }

// fn bench_parse(bench: &mut Bench) {
//     bench.task("guess wrapped", |task| {
//         task.iter(|| {
//             for hjson in GIFTS {
//                 let guessed = from_str::<WrappedGuess>(hjson)
//                     .unwrap_or_else(|e| panic!("Parsing failed for {:?} : {}", hjson, e));
//                 pretend_used(guessed);
//             }
//         });
//     });
// }
// glassbench!(
//     "Parse",
//     bench_parse,
// );