slice/
slice.rs

1
2use std::fmt::Debug;
3
4#[macro_use]
5extern crate cluStaticData;
6
7static_data! {
8	pub(crate) static ref TEST: &'static dyn MyTrait = &();
9}
10
11pub trait MyTrait: Debug + Sync {
12	fn is_true(&self) -> bool {
13		false
14	}
15}
16
17impl MyTrait for () {
18	
19}
20
21impl MyTrait for usize {
22	#[inline]
23	fn is_true(&self) -> bool {
24		self > &0
25	}
26}
27
28fn main() {
29	assert_eq!(TEST.is_true(), false);
30	println!("OK #0 {:?}", TEST);
31	
32	let err = TEST.set(&10);
33	assert_eq!(TEST.is_true(), true);
34	println!("OK #1 {:?}, result: {:?}", TEST, err);
35}