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
use read_only::cast;
mod m {
use super::cast;
#[cast]
pub struct Many {
#[readonly]
pub a: i32,
#[readonly]
pub b: f64,
pub c: bool,
#[readonly]
pub d: String,
pub e: char,
f: u8,
#[readonly]
pub g: i16,
}
impl Many {
pub fn new() -> Self {
Self {
a: 1,
b: 2.0,
c: true,
d: String::from("hello"),
e: 'x',
f: 0,
g: 42,
}
}
}
}
fn main() {
let mut demo = m::Many::new();
let _ = demo.a + demo.b as i32;
demo.c = false;
let _ = &demo.d;
let _ = demo.e;
let _ = demo.g;
}