yfunc_rust/
lib.rs

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
mod error;
mod ytime;
mod yuid;
mod func;
mod page;
mod ybytes;

pub use error::*;
pub use ytime::YTime;
pub use yuid::YUid;
pub use func::*;
pub use page::Page;
pub use ybytes::YBytes;

pub mod prelude {
    pub use crate::{YRes, YError, Trace, err, ctx};
}

#[cfg(test)]
mod tests {

    use super::*;

    #[test]
    fn err_works() {
        let x = 3; 
        let y = "t";
        err!(ParseError).print();
        err!(ParseError::"parse A to B").print();
        err!(ParseError, x).print();
        err!(ParseError::"parse A to B", y).print();
        err!(ParseError::"parse A to B": "parse json field F failed").print();
        err!(ParseError::"parse A to B": "parse json field F failed", x, y).print();        
    }

    #[test]
    fn ctx_works() {
        let x = 3; 
        let y = "t";
        println!("{}", ctx!());
        println!("{}", ctx!("parse A to B"));
        println!("{}", ctx!(x));
        println!("{}", ctx!(y));
        println!("{}", ctx!(y, x));
        println!("{}", ctx!("parse A to B", y));
        println!("{}", ctx!("parse A to B": "parse json field F failed"));
        println!("{}", ctx!("parse A to B": "parse json field F failed", x, y));
    }
}