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
44
45
46
47
48
49
50
use std::mem;
pub trait CL{fn c_len(&self)->usize;}
macro_rules! cl_impls_2{($type:ty,$($N:expr)+)=>{$(
impl CL for [$type;$N]{fn c_len(&self)->usize{$N}}
)+}}
macro_rules! cl_impls{($($type:ty)+)=>{$(
impl CL for $type{fn c_len(&self)->usize{1}}
impl CL for Vec<$type>{fn c_len(&self)->usize{self.len()}}
cl_impls_2!($type,
00 01 02 03 04 05 06 07 08 09
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
);
)+}}
cl_impls!(u8 i8 u16 i16 u32 i32 u64 i64);
impl CL for String{fn c_len(&self)->usize{self.len()}}
impl CL for str{fn c_len(&self)->usize{self.len()}}
impl<'a,T> CL for &'a T where T:CL+?Sized{fn c_len(&self)->usize{(*self).c_len()}}
pub trait CS{fn c_size(&self)->usize;}
macro_rules! cs_impls_2{($type:ty,$($N:expr)+)=>{$(
impl CS for [$type;$N]{fn c_size(&self)->usize{mem::size_of::<$type>()}}
)+}}
macro_rules! cs_impls{($($type:ty)+)=>{$(
impl CS for $type{fn c_size(&self)->usize{mem::size_of::<$type>()}}
impl CS for Vec<$type>{fn c_size(&self)->usize{mem::size_of::<$type>()}}
cs_impls_2!($type,
00 01 02 03 04 05 06 07 08 09
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
);
)+}}
cs_impls!(u8 i8 u16 i16 u32 i32 u64 i64);
impl CS for String{fn c_size(&self)->usize{1}}
impl CS for str{fn c_size(&self)->usize{1}}
impl<'a,T> CS for &'a T where T:CS+?Sized{fn c_size(&self)->usize{(*self).c_size()}}
include!("./mod_empty.rs");
include!("./cNcpp.rs");