| 1 | #![cfg(feature = "serde")] |
| 2 | |
| 3 | use bitarrayrust-analyzer cargo bitarray 0.10.0 crate/::BitArrayrust-analyzer cargo bitarray 0.10.0 BitArray#; |
| 4 | |
| 5 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 6 | fn bincode_serde_json_cyclerust-analyzer cargo bitarray 0.10.0 bincode_serde_json_cycle().() { |
| 7 | let old_bits = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![BitArrayrust-analyzer cargo bitarray 0.10.0 BitArray#::newrust-analyzer cargo bitarray 0.10.0 impl#[`BitArray<B>`]new().([0, 1, 2, 3, 255])]; |
| 8 | let mut bdata = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 9 | bincoderust-analyzer cargo bincode 1.3.3 crate/::serialize_intorust-analyzer cargo bincode 1.3.3 serialize_into().(&mut bdata, &old_bits).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("failed to serialize with bincode"); |
| 10 | let middle_bits: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BitArrayrust-analyzer cargo bitarray 0.10.0 BitArray#<5>> = |
| 11 | bincoderust-analyzer cargo bincode 1.3.3 crate/::deserialize_fromrust-analyzer cargo bincode 1.3.3 deserialize_from().(bdata.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().()).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("failed to deserialize with bincode"); |
| 12 | let new_bits: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BitArrayrust-analyzer cargo bitarray 0.10.0 BitArray#<5>> = serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::from_strrust-analyzer cargo serde_json 1.0.151 de/from_str().( |
| 13 | &serde_jsonrust-analyzer cargo serde_json 1.0.151 crate/::to_stringrust-analyzer cargo serde_json 1.0.151 ser/to_string().(&middle_bits).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("failed to serialize with serde_json"), |
| 14 | ) |
| 15 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("failed to deserialize with serde_json"); |
| 16 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(old_bits, new_bits); |
| 17 | } |