lcrt-macro

Crates.iolcrt-macro
lib.rslcrt-macro
version0.1.0
sourcesrc
created_at2023-02-08 06:54:10.392157
updated_at2023-02-08 06:54:10.392157
descriptionA simple utility crate to help writing leetcode solutions in rust.
homepage
repositoryhttps://github.com/r12f/lcrt
max_upload_size
id779427
size22,807
Riff (r12f)

documentation

README

LCRT (Leetcode Runtime)

Crates.io License: Apache 2.0

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.

How to use

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>> {
        }
    }
}

License

Apache-2.0: https://www.apache.org/licenses/LICENSE-2.0

Commit count: 19

cargo fmt