rustgym/
lib.rs

1//! # Install dependencies
2//! ##  macos
3//! ```bash
4//! brew install graphviz
5//! ```
6//! ## linux
7//! ```bash
8//! apt install graphviz
9//! ```
10//! # Handy macros to build data for testing
11//! ```
12//! use rustgym_util::*;
13//!
14//! // singly linked list
15//! let list = list!(1, 2, 3);
16//! // binary tree
17//! let root = tree!(1, tree!(2, tree!(3), tree!(4)), None);
18//! // 1D vector of String
19//! let names = vec_string!["Larry Fantasy", "Yinchu Xia"];
20//! // 2D vector of String
21//! let names_2d = vec_vec_string![["Larry", "Fantasy"], ["Yinchu", "Xia"]];
22//! // 2D vector of i32
23//! let matrix_i32 = vec_vec_i32![[1, 2], [3, 4]];
24//! // 2D vector of char
25//! let matrix_char = vec_vec_char![['a', 'b'], ['c', 'd']];
26//! ```
27//! # Boilerplate for singly linked list
28//! Replace
29//! ```
30//! use rustgym_util::*;
31//! ```
32//! with
33//! ```ignore
34//! #[macro_export]
35//! macro_rules! list {
36//!     () => {
37//!         None
38//!     };
39//!     ($e:expr) => {
40//!         ListLink::link($e, None)
41//!     };
42//!     ($e:expr, $($tail:tt)*) => {
43//!         ListLink::link($e, list!($($tail)*))
44//!     };
45//! }
46//!
47//! pub type ListLink = Option<Box<ListNode>>;
48//!
49//! pub trait ListMaker {
50//!     fn link(val: i32, next: ListLink) -> ListLink {
51//!         Some(Box::new(ListNode { val, next }))
52//!     }
53//! }
54//!
55//! impl ListMaker for ListLink {}
56//! ```
57//! when submitting to leetcode online judge.
58//!
59//! # Boilerplate for binary tree
60//! Replace
61//! ```
62//! use rustgym_util::*;
63//! ```
64//! with
65//! ```ignore
66//! #[macro_export]
67//! macro_rules! tree {
68//!     ($e:expr) => {
69//!         TreeLink::leaf($e)
70//!     };
71//!     ($e:expr, $l:expr, $r:expr) => {
72//!         TreeLink::branch($e, $l, $r)
73//!     };
74//! }
75//!
76//! pub type TreeLink = Option<Rc<RefCell<TreeNode>>>;
77//!
78//! use std::cell::RefCell;
79//! use std::rc::Rc;
80//!
81//! pub trait TreeMaker {
82//!     fn branch(val: i32, left: TreeLink, right: TreeLink) -> TreeLink {
83//!         Some(Rc::new(RefCell::new(TreeNode { val, left, right })))
84//!     }
85//!     fn leaf(val: i32) -> TreeLink {
86//!         Some(Rc::new(RefCell::new(TreeNode {
87//!             val,
88//!             left: None,
89//!             right: None,
90//!         })))
91//!     }
92//! }
93//! ```
94//! when submitting to leetcode online judge.
95#[cfg_attr(test, macro_use)]
96extern crate rustgym_util;
97
98#[allow(dead_code)]
99#[deny(clippy::all)]
100#[allow(clippy::collapsible_if)]
101#[allow(clippy::needless_range_loop)]
102#[allow(clippy::too_many_arguments)]
103mod leetcode;
104
105#[allow(dead_code)]
106#[deny(clippy::all)]
107#[allow(clippy::collapsible_if)]
108#[allow(clippy::needless_range_loop)]
109#[allow(clippy::too_many_arguments)]
110mod hackerrank;