Crates.io | lcrt-macro |
lib.rs | lcrt-macro |
version | 0.1.0 |
source | src |
created_at | 2023-02-08 06:54:10.392157 |
updated_at | 2023-02-08 06:54:10.392157 |
description | A simple utility crate to help writing leetcode solutions in rust. |
homepage | |
repository | https://github.com/r12f/lcrt |
max_upload_size | |
id | 779427 |
size | 22,807 |
LCRT is a really simple utility crate to help writing leetcode solutions in rust. It leverages proc macros in rust to reduce the boilerplate code that we need to write.
To use this library, please add the following into the dependencies in the Cargo.toml
file:
[dependencies]
lcrt-macro = "0.1"
lcrt = "0.1"
Then in your local library, in lib.rs
file, please add the macro use as below.
#[macro_use]
extern crate lcrt_macro;
Then we can start writing code like this:
#[solution]
impl Solution {
pub fn add_two_numbers(
_l1: Option<Box<ListNode>>,
_l2: Option<Box<ListNode>>,
) -> Option<Box<ListNode>> {
None
}
}
Underlying, it will alternate the code as below:
mod p2_add_two_numbers {
use lcrt::*;
pub struct Solution {}
impl Solution {
pub fn add_two_numbers(
l1: Option<Box<ListNode>>,
l2: Option<Box<ListNode>>,
) -> Option<Box<ListNode>> {
}
}
}
Apache-2.0: https://www.apache.org/licenses/LICENSE-2.0