File: const.rs

package info (click to toggle)
rust-serde-big-array 0.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 144 kB
  • sloc: makefile: 2
file content (20 lines) | stat: -rw-r--r-- 426 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#![no_std]

use serde_big_array::BigArray;
use serde_derive::{Deserialize, Serialize};

const NUMBER: usize = 127;

#[derive(Serialize, Deserialize)]
struct S {
    #[serde(with = "BigArray")]
    arr: [u8; NUMBER],
}

#[test]
fn test() {
    let s = S { arr: [1; NUMBER] };
    let j = serde_json::to_string(&s).unwrap();
    let s_back = serde_json::from_str::<S>(&j).unwrap();
    assert!(&s.arr[..] == &s_back.arr[..]);
}