yfunc_rust/
lib.rs

1#![allow(non_snake_case)]
2#![allow(non_upper_case_globals)]
3
4mod error;
5mod ytime;
6mod yuid;
7mod func;
8mod page;
9mod ybytes;
10
11pub use error::*;
12pub use ytime::YTime;
13pub use yuid::YUid;
14pub use func::*;
15pub use page::Page;
16pub use ybytes::YBytes;
17pub use yfunc_rust_macro::yfunc;
18
19pub mod prelude {
20    pub use crate::{yfunc, YRes, YError, Trace, err, ctx, INTERNAL_ERROR};
21    pub use log::{debug, trace, info, warn, error};
22}
23
24#[cfg(test)]
25mod tests {
26
27    use super::*;
28
29    #[test]
30    fn err_works() {
31        let x = 3; 
32        let y = "test";
33        println!("{:?}", err!());
34        println!("{:?}", err!("something failed"));
35        println!("{:?}", err!("something failed, x={}", 3));
36        println!("{:?}", err!("SOME_ERROR": "something failed"));
37        println!("{:?}", err!("SOME_ERROR": "something failed, x={}, y={}", x, y));
38    }
39
40    #[test]
41    fn ctx_works() {
42        let x = 3; 
43        let y = "test";
44        println!("{}", ctx!());
45        println!("{}", ctx!("A -> B -> C"));
46        println!("{}", ctx!(x));
47        println!("{}", ctx!(y));
48        println!("{}", ctx!(y, x));
49        println!("{}", ctx!("A -> B -> C: D", x, y));
50    }
51
52    #[test]
53    fn unique_works() {
54        let list = vec!["123", "345", "123", "222"];
55        println!("{:?}", list.unique())
56    }
57
58}