Debian Codegraph @

tests/bennofs.rs

raw symbols SCIP
1 #[macro_use]
2 extern crate serderust-analyzer cargo serde_cbor_2 0.13.0 serde/;
3
4 use serderust-analyzer cargo serde 1.0.144 crate/::Serializerust-analyzer cargo serde 1.0.144 ser/Serialize#;
5 use serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::serrust-analyzer cargo serde_cbor_2 0.13.0 ser/::SliceWriterust-analyzer cargo serde_cbor_2 0.13.0 write/SliceWrite#;
6 use serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::{selfrust-analyzer cargo serde_cbor_2 0.13.0 crate/, Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#};
7
8 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.144 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.144 Deserialize:)]
9 struct Examplerust-analyzer cargo serde_cbor_2 0.13.0 Example# {
10 foorust-analyzer cargo serde_cbor_2 0.13.0 Example#foo.: Foorust-analyzer cargo serde_cbor_2 0.13.0 Foo#,
11 payloadrust-analyzer cargo serde_cbor_2 0.13.0 Example#payload.: u8,
12 }
13
14 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.144 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.144 Deserialize:)]
15 struct Foorust-analyzer cargo serde_cbor_2 0.13.0 Foo# {
16 xrust-analyzer cargo serde_cbor_2 0.13.0 Foo#x.: u8,
17 colorrust-analyzer cargo serde_cbor_2 0.13.0 Foo#color.: Colorrust-analyzer cargo serde_cbor_2 0.13.0 Color#,
18 }
19
20 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.144 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.144 Deserialize:)]
21 enum Colorrust-analyzer cargo serde_cbor_2 0.13.0 Color# {
22 Redrust-analyzer cargo serde_cbor_2 0.13.0 Color#Red#,
23 Bluerust-analyzer cargo serde_cbor_2 0.13.0 Color#Blue#,
24 Yellowrust-analyzer cargo serde_cbor_2 0.13.0 Color#Yellow#(u8),
25 }
26
27 const EXAMPLErust-analyzer cargo serde_cbor_2 0.13.0 EXAMPLE.: Examplerust-analyzer cargo serde_cbor_2 0.13.0 Example# = Examplerust-analyzer cargo serde_cbor_2 0.13.0 Example# {
28 foorust-analyzer cargo serde_cbor_2 0.13.0 Example#foo.: Foorust-analyzer cargo serde_cbor_2 0.13.0 Foo# {
29 xrust-analyzer cargo serde_cbor_2 0.13.0 Foo#x.: 0xAA,
30 colorrust-analyzer cargo serde_cbor_2 0.13.0 Foo#color.: Colorrust-analyzer cargo serde_cbor_2 0.13.0 Color#::Yellowrust-analyzer cargo serde_cbor_2 0.13.0 Color#Yellow#(40),
31 },
32 payloadrust-analyzer cargo serde_cbor_2 0.13.0 Example#payload.: 0xCC,
33 };
34
35 #[cfg(feature = "std")]
36 mod std_testsrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/ {
37 use superrust-analyzer cargo serde_cbor_2 0.13.0 crate/::*;
38
39 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
40 fn testrust-analyzer cargo serde_cbor_2 0.13.0 std_tests/test().() {
41 let serialized = serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::serrust-analyzer cargo serde_cbor_2 0.13.0 ser/::to_vec_packedrust-analyzer cargo serde_cbor_2 0.13.0 ser/to_vec_packed().(&EXAMPLErust-analyzer cargo serde_cbor_2 0.13.0 EXAMPLE.).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("bennofs 1");
42 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{serialized:?}");
43 let deserialized: Examplerust-analyzer cargo serde_cbor_2 0.13.0 Example# = serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::from_slicerust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice().(&serialized).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("bennofs 2");
44 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(EXAMPLErust-analyzer cargo serde_cbor_2 0.13.0 EXAMPLE., deserialized);
45 }
46 }
47
48 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
49 fn testrust-analyzer cargo serde_cbor_2 0.13.0 test().() {
50 let mut slice = [0u8; 64];
51 let writer = SliceWriterust-analyzer cargo serde_cbor_2 0.13.0 write/SliceWrite#::newrust-analyzer cargo serde_cbor_2 0.13.0 write/impl#[`SliceWrite<'a>`]new().(&mut slice);
52 let mut serializer = Serializerrust-analyzer cargo serde_cbor_2 0.13.0 ser/Serializer#::newrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]new().(writer).packed_formatrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]packed_format().();
53 EXAMPLErust-analyzer cargo serde_cbor_2 0.13.0 EXAMPLE..serializerust-analyzer cargo serde_cbor_2 0.13.0 impl#[Example][Serialize]serialize().(&mut serializer).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
54 let writer = serializer.into_innerrust-analyzer cargo serde_cbor_2 0.13.0 ser/impl#[`Serializer<W>`]into_inner().();
55 let end = writer.bytes_writtenrust-analyzer cargo serde_cbor_2 0.13.0 write/impl#[`SliceWrite<'a>`]bytes_written().();
56 let slice = writer.into_innerrust-analyzer cargo serde_cbor_2 0.13.0 write/impl#[`SliceWrite<'a>`]into_inner().();
57 let deserialized: Examplerust-analyzer cargo serde_cbor_2 0.13.0 Example# =
58 serde_cbor_2rust-analyzer cargo serde_cbor_2 0.13.0 crate/::derust-analyzer cargo serde_cbor_2 0.13.0 de/::from_slice_with_scratchrust-analyzer cargo serde_cbor_2 0.13.0 de/from_slice_with_scratch().(&slice[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &mut []).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
59 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(EXAMPLErust-analyzer cargo serde_cbor_2 0.13.0 EXAMPLE., deserialized);
60 }