leetcode_prelude

Crates.ioleetcode_prelude
lib.rsleetcode_prelude
version0.2.3
sourcesrc
created_at2018-12-29 10:50:12.874321
updated_at2020-08-14 12:56:24.883619
descriptionSome useful macros and definition for exercising in leetcode
homepagehttps://github.com/Aloxaf/leetcode_prelude
repositoryhttps://github.com/Aloxaf/leetcode_prelude
max_upload_size
id104382
size6,880
Aloxaf (Aloxaf)

documentation

README

leetcode_prelude

Some useful macros and definition for exercising in LeetCode.

How to use

Add following lines to your Cargo.toml.

[dependencies]
leetcode_prelude = "^0.2"

Examples

Binary tree initialization

use leetcode_prelude::btree;

let btree = btree![1, 2, 2, null, null, 3, 3];

Linked list initialization

use leetcode_prelude::linkedlist;

let linkedlist = linkedlist![1, 2, 3];

Generate test code from leetcode's json

use leetcode_prelude::leetcode_test;

leetcode_test!(
     ["Trie", "insert", "search"]
     [[], ["apple"], ["apple"]]
     [null, null, true]
)

Create a Vec<String>

use leetcode_prelude::vec_string;

let vec = vec_string!["1", "2", "3"];

assert_eq_sorted

use leetcode_prelude::assert_eq_sorted;

assert_eq_sorted!(vec![1, 2], vec![2, 1]);
Commit count: 21

cargo fmt