Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c6e0d0a

Browse files
Updated README.md description
1 parent d7f66ef commit c6e0d0a

File tree

1 file changed

+90
-7
lines changed

1 file changed

+90
-7
lines changed

‎README.md

Lines changed: 90 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
# LeetCode Trees in Rust
22

3-
[![Build Status]][Actions] [![Latest Version]][crates.io]
3+
[![Build Status]][Actions] [![Latest Version]][crates.io]
44

55
[Build Status]: https://img.shields.io/github/actions/workflow/status/1kill2steal/leetcode-trees-rs/rust.yml?branch=main
66
[Actions]: https://github.com/1kill2steal/leetcode-trees-rs/actions?query=branch%3Amaster
77
[Latest Version]: https://img.shields.io/crates/v/leetcode-trees-rs.svg
88
[crates.io]: https://crates.io/crates/leetcode-trees-rs
99

10+
## Description
11+
1012
This library is made to make any LeetCoders using Rust have a better experience
1113
at solving their LeetCode (LC) problems. It uses cargo make to have
1214
reproducible sub modules (check `leetcode-trees-rs/solutions/README.md`) as
1315
well as implementing the definition of the binary trees on LC.
1416

17+
---
18+
1519
Quick start on using the library:
1620

21+
## For `TreeNode` values (Binary Trees)
22+
1723
```rust
18-
use leetcode_trees_rs::{prelude::*, utils::TreeNode}; // Importing the library.
24+
use leetcode_trees_rs::{
25+
prelude::*,
26+
utils::{symmetric_tree, tree, TreeNode},
27+
};
1928

2029
struct Solution {} // Assigning an empty struct to make a solution impl block.
2130

@@ -24,19 +33,93 @@ impl Solution {
2433
pub fn your_leetcode_fn() {}
2534
}
2635

36+
#[cfg(test)]
37+
mod tests {
38+
#[test]
39+
fn tests() {
40+
// . . .
41+
}
42+
}
43+
2744
fn main() -> Result<()> {
28-
// Your testing here . . .
29-
// Alternatively, you can just use functions with #[test] definitions.
45+
// Equivalent of:
46+
// 1
47+
// 2 2
48+
// 3 3 3 3
49+
let symmetric_tree_node = symmetric_tree!(1, 2, 3);
50+
51+
// Equivalent of:
52+
// 1
53+
// 2 #
54+
// 3 3 # #
55+
// 4 # # # # # # #
56+
let custom_tree = tree!(&[
57+
vec![Some(1)],
58+
vec![Some(2), None],
59+
vec![Some(3), Some(3)],
60+
vec![Some(4)],
61+
]);
62+
63+
// If you want trees that only branch to the left or to the right then
64+
// there're also the `left_tree!()` and `right_tree!()` macros!
65+
// Those macros can help you write your test runs easier.
3066

3167
Ok(())
3268
}
3369
```
3470

35-
Additional features:
71+
---
72+
73+
## For `ListNode` values (Singly Linked Lists)
3674

37-
- Singly Linked Lists (example Leet - [add two numbers](https://leetcode.com/problems/add-two-numbers/description/))
75+
```rust
76+
use leetcode_trees_rs::{list_node, prelude::*, utils::ListNode};
77+
78+
struct Solution {} // Assigning an empty struct to make a solution impl block.
3879

39-
- Macros (for Trees and Linked Lists)
80+
use std::{cell::RefCell, rc::Rc};
81+
impl Solution {
82+
pub fn your_leetcode_fn() {}
83+
}
84+
85+
#[cfg(test)]
86+
mod tests {
87+
#[test]
88+
fn tests() {
89+
// . . .
90+
}
91+
}
92+
93+
fn main() -> Result<()> {
94+
// This is the very cumbersome manual way of writing your ListNode structs.
95+
let some_list = ListNode {
96+
val: 1,
97+
next: Some(Box::new(ListNode {
98+
val: 2,
99+
next: Some(Box::new(ListNode::new(3))),
100+
})),
101+
};
102+
// And this is the easier way:
103+
let another_list = list_node!(1, 2, 3);
104+
105+
assert_eq!(some_list, another_list);
106+
107+
Ok(())
108+
}
109+
```
110+
111+
## LICENSE
112+
113+
The project is licensed under the MIT license.
114+
115+
## Extra notes
116+
117+
---
40118

41119
Additional code templating can be found in [This template file](https://github.com/1Kill2Steal/leetcode-trees-rs/blob/main/solutions/lc0_general_nodes_template/src/main.rs).
120+
42121
It's located at: `solutions/lc0_general_nodes_template/src/main.rs`
122+
123+
---
124+
125+
Additional documentation can be found in [docs.rs](https://docs.rs/leetcode-trees-rs/latest/leetcode_trees_rs/).

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /