cargo_leet/lib.rs
1#![forbid(unsafe_code)]
2#![warn(missing_docs)]
3#![warn(rustdoc::missing_crate_level_docs)]
4#![warn(unreachable_pub)]
5#![warn(missing_debug_implementations)]
6#![warn(clippy::pedantic)]
7#![warn(clippy::cargo)]
8#![warn(clippy::nursery)] // these might be false positives, so we need to check these on a case-by-case basis
9#![allow(clippy::redundant_pub_crate)] // this lint is giving too many false positives
10
11//! The main aim of **cargo-leet** is to make it easier to develop solutions to
12//! leetcode problems locally on your machine. And as such it is composed of two
13//! parts, a tool to help with code download and testing setup, and helper code
14//! to allow running solutions developed locally.
15//!
16//! ### Tool
17//!
18//! The **cargo-leet** subcommand is a command line tool developed with clap and
19//! the associated help is probably the best way to get an idea of how to use
20//! the tool. Help messages can be found in the
21//! [readme](https://github.com/rust-practice/cargo-leet#Help#Messages) on GitHub.
22//! For the sake of maintainability features added will be documented there
23//! instead of always needing to update multiple places.
24//!
25//! ### Leetcode Environment Support
26//!
27//! **cargo-leet** also includes helper code with structs and traits to simulate
28//! the environment that your code would run in on the leetcode servers so that
29//! you are able to run tests on your code locally. It also provides a few extra
30//! types that facilitate testing especially as it relates to creating test
31//! cases from the text provided by leetcode.
32//!
33//! ## Feature flags
34//! **cargo-leet** uses feature flags to control which code gets compiled based
35//! on how the crate is being used. This is especially important for the code
36//! imported in the solution repository as this repo may be using an older
37//! version of the rust toolchain (as of 2024-02-02 the version leetcode uses
38//! is 1.74.1 found in their
39//! [Help Center](https://support.leetcode.com/hc/en-us/articles/360011833974-What-are-the-environments-for-the-programming-languages)
40//! ) due to the fact that leetcode uses a much
41//! older version on their servers and some users may want to use the same
42//! version to ensure their code will always work upon upload.
43//! However, because the toolchain used by leetcode cannot compile many of the
44//! crates used in the development of the tool due to leetcode's old version,
45//! compiling them only behind a feature flag makes that a non-issue. It also
46//! allows users to not compile the code only needed to support leetcode
47//! solution development when working on or using the tool.
48//!
49//! - `default`: Enables the `leet_env` feature as this is the most common use
50//! case
51//! - `leet_env`: Includes the code for working on leetcode problem solutions
52//! - `tool`: Enables the code and dependencies used to create the tool.
53
54#[cfg(feature = "leet_env")]
55pub use leetcode_env::{
56 list::{ListHead, ListNode},
57 tree::{TreeNode, TreeRoot},
58};
59
60#[cfg(feature = "tool")]
61pub use crate::tool::{cli::TopLevel, core::run, log::init_logging};
62
63#[cfg(feature = "leet_env")]
64mod leetcode_env;
65#[cfg(feature = "tool")]
66mod tool;