is_debug-1.1.0/.cargo_vcs_info.json0000644000000001360000000000100126140ustar { "git": { "sha1": "6f64716442030267ff23ae446b1dd791880c8fec" }, "path_in_vcs": "" }is_debug-1.1.0/.github/dependabot.yml000064400000000000000000000005431046102023000155760ustar 00000000000000version: 2 updates: - package-ecosystem: cargo directory: "/" schedule: interval: daily open-pull-requests-limit: 10 labels: - "\U0001F4E6 dependencies" - package-ecosystem: github-actions directory: "/" schedule: interval: daily open-pull-requests-limit: 10 labels: - "\U0001F4E6 dependencies" is_debug-1.1.0/.github/workflows/check.yml000064400000000000000000000030431046102023000166010ustar 00000000000000name: check on: push: branches: - "*" tags: - "*" pull_request: branches: - "*" jobs: build: strategy: matrix: os: - ubuntu-latest - macos-latest - windows-latest runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v4 with: submodules: true - uses: actions-rs/toolchain@v1 with: toolchain: stable override: true components: clippy, rustfmt - name: Check format run: cargo fmt --all -- --check - name: Check fix run: cargo fix && cargo fix - name: Check with clippy run: cargo clippy --all-targets --all-features -- -D warnings - name: Build Release run: cargo build --release - name: Run tests run: cargo test - uses: dtolnay/rust-toolchain@v1 with: target: riscv32imc-unknown-none-elf toolchain: stable components: rust-src - name: Run no_std example run: | cargo fmt --all -- --check cargo clippy --release --all -- -D warnings cargo b --release working-directory: ./is_debug_no_std publish-crate: if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: - name: Set up Rust uses: hecrj/setup-rust-action@v2 - uses: actions/checkout@v4 - name: Publish shell: bash run: | cargo publish --token ${{ secrets.CRATES_GITHUB_TOKEN }} is_debug-1.1.0/.gitignore000064400000000000000000000000311046102023000133660ustar 00000000000000/target Cargo.lock .idea/is_debug-1.1.0/Cargo.lock0000644000000011360000000000100105700ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 4 [[package]] name = "is_debug" version = "1.1.0" dependencies = [ "xshell", ] [[package]] name = "xshell" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e7290c623014758632efe00737145b6867b66292c42167f2ec381eb566a373d" dependencies = [ "xshell-macros", ] [[package]] name = "xshell-macros" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547" is_debug-1.1.0/Cargo.toml0000644000000021450000000000100106140ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "is_debug" version = "1.1.0" authors = ["baoyachi "] build = false autolib = false autobins = false autoexamples = false autotests = false autobenches = false description = "get build model is debug" readme = "README.md" keywords = [ "build", "build-model", "model", "debug", "release", ] categories = [ "development-tools", "development-tools::build-utils", ] license = "MIT AND Apache-2.0" repository = "https://github.com/baoyachi/rust_is_debug" [lib] name = "is_debug" path = "lib.rs" [dev-dependencies.xshell] version = "0.2.7" [features] default = ["std"] std = [] is_debug-1.1.0/Cargo.toml.orig000064400000000000000000000007271046102023000143010ustar 00000000000000[package] name = "is_debug" version = "1.1.0" authors = ["baoyachi "] description = "get build model is debug" keywords = ["build", "build-model", "model", "debug", "release"] categories = ["development-tools", "development-tools::build-utils"] repository = "https://github.com/baoyachi/rust_is_debug" license = "MIT AND Apache-2.0" edition = "2018" [lib] path = "lib.rs" [features] default = ["std"] std = [] [dev-dependencies] xshell = "0.2.7" is_debug-1.1.0/LICENSE000064400000000000000000000020511046102023000124070ustar 00000000000000MIT License Copyright (c) 2021 baoyachi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. is_debug-1.1.0/README.md000064400000000000000000000003701046102023000126630ustar 00000000000000# is_debug The crate by Rust that get build model is debug. ### use function ```TOML [dependencies] is_debug = "1" ``` ```rust use is_debug::{is_debug, is_release}; fn main() { println!("{}", is_debug()); println!("{}", is_release()); } ``` is_debug-1.1.0/lib.rs000064400000000000000000000035041046102023000125220ustar 00000000000000#![cfg_attr(not(feature = "std"), no_std)] mod core { #[cfg(not(feature = "std"))] pub use core::*; #[cfg(feature = "std")] pub use std::*; } pub use self::core::cmp::PartialEq; pub use self::core::prelude::*; pub use self::core::{cfg, fmt, fmt::Debug, matches}; pub enum BuildModel { Debug, Release, } pub const fn build_channel() -> BuildModel { if cfg!(debug_assertions) { return BuildModel::Debug; } BuildModel::Release } impl fmt::Display for BuildModel { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Debug => f.write_str("debug"), Self::Release => f.write_str("release"), } } } pub const fn is_debug() -> bool { matches!(build_channel(), BuildModel::Debug) } pub const fn is_release() -> bool { matches!(build_channel(), BuildModel::Release) } #[cfg(test)] mod tests { use xshell::{cmd, Shell}; #[test] fn test_std() { let sh = Shell::new().unwrap(); let repo = "is_debug_test"; let _ = cmd!(sh, "rm -rf {repo}").run(); cmd!(sh, "cargo new {repo}").run().unwrap(); sh.change_dir(repo); let cargo_content = r#" [package] name = "is_debug_test" version = "0.1.0" edition = "2021" [dependencies] is_debug = {path = "../"} "#; sh.write_file("Cargo.toml", cargo_content).unwrap(); let main_debug = r#" fn main() { assert!(is_debug::is_debug()) } "#; let main_release = r#" fn main() { assert!(is_debug::is_release()) } "#; sh.write_file("src/main.rs", main_debug).unwrap(); cmd!(sh, "cargo run").run().unwrap(); sh.write_file("src/main.rs", main_release).unwrap(); cmd!(sh, "cargo run --release").run().unwrap(); cmd!(sh, "rm -rf ../{repo}").run().unwrap(); } }