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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! # Handy macros to build data for testing
//! ```
//! use rustgym_util::*;
//!
//! // singly linked list
//! let list = list!(1, 2, 3);
//! // binary tree
//! let root = tree!(1, tree!(2, tree!(3), tree!(4)), None);
//! // 1D vector of String
//! let names = vec_string!["Larry Fantasy", "Yinchu Xia"];
//! // 2D vector of String
//! let names_2d = vec_vec_string![["Larry", "Fantasy"], ["Yinchu", "Xia"]];
//! // 2D vector of i32
//! let matrix_i32 = vec_vec_i32![[1, 2], [3, 4]];
//! // 2D vector of char
//! let matrix_char = vec_vec_char![['a', 'b'], ['c', 'd']];
//! ```
//! # Boilerplate for singly linked list
//! Replace
//! ```
//! use rustgym::util::*;
//! ```
//! with
//! ```compile_fail
//! #[macro_export]
//! macro_rules! list {
//!     () => {
//!         None
//!     };
//!     ($e:expr) => {
//!         ListLink::link($e, None)
//!     };
//!     ($e:expr, $($tail:tt)*) => {
//!         ListLink::link($e, list!($($tail)*))
//!     };
//! }
//!
//! pub type ListLink = Option<Box<ListNode>>;
//!
//! pub trait ListMaker {
//!     fn link(val: i32, next: ListLink) -> ListLink {
//!         Some(Box::new(ListNode { val, next }))
//!     }
//! }
//!
//! impl ListMaker for ListLink {}
//! ```
//! when submitting to leetcode online judge.
//!
//! # Boilerplate for binary tree
//! Replace
//! ```
//! use rustgym::util::*;
//! ```
//! with
//! ```compile_fail
//! #[macro_export]
//! macro_rules! tree {
//!     ($e:expr) => {
//!         TreeLink::leaf($e)
//!     };
//!     ($e:expr, $l:expr, $r:expr) => {
//!         TreeLink::branch($e, $l, $r)
//!     };
//! }
//!
//! pub type TreeLink = Option<Rc<RefCell<TreeNode>>>;
//!
//! use std::cell::RefCell;
//! use std::rc::Rc;
//!
//! pub trait TreeMaker {
//!     fn branch(val: i32, left: TreeLink, right: TreeLink) -> TreeLink {
//!         Some(Rc::new(RefCell::new(TreeNode { val, left, right })))
//!     }
//!     fn leaf(val: i32) -> TreeLink {
//!         Some(Rc::new(RefCell::new(TreeNode {
//!             val,
//!             left: None,
//!             right: None,
//!         })))
//!     }
//! }
//! ```
//! when submitting to leetcode online judge.
#[cfg_attr(test, macro_use)]
pub extern crate rustgym_util as util;

#[allow(dead_code)]
#[deny(clippy::all)]
#[allow(clippy::collapsible_if)]
#[allow(clippy::needless_range_loop)]
#[allow(clippy::too_many_arguments)]
mod leetcode;