diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98dd3df..59abfe4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: uses: dtolnay/rust-toolchain@1.70 - name: Check tests - run: cargo test --all-features --no-run && cargo test + run: export ENV_VAR=69 && export NENV_VAR=-69 && cargo test --all-features --no-run && cargo test tests: runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index af0cda9..7040118 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -201,7 +201,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "typenum-consts" -version = "0.1.1" +version = "0.1.2" dependencies = [ "dotenv", "peekmore", diff --git a/Cargo.toml b/Cargo.toml index d57a703..b2a120c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "typenum-consts" -version = "0.1.1" +version = "0.1.2" edition = "2021" authors = ["Jim Chng "] exclude = [ diff --git a/README.md b/README.md index dfcbb50..7a1cd8d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Procedural macros that take a literal integer (or the result of an evaluation of ### It saves time. -Assuming you want a type-level positive integer `84938493`, `tnconst![+84938493]` outputs directly `typenum::PInt` (by the way, `U84938493` does not exist in `typenum::consts`). The alternative is to type `PInt, ...>, ...>, ...>` (which argubly takes a lot more time). +Assuming you want a type-level positive integer `84938493`, `tnconst![+84938493]` outputs directly `typenum::PInt` (by the way, `U84938493` does not exist in `typenum::consts`). The alternative is to type `PInt, ...>, ...>, ...>` (which argubly takes a lot more time). Example: @@ -55,7 +55,7 @@ assert_eq!( ### For conditional compilation. -Suppose in different environments you want a different type-level integer, you can either use `#[cfg(production)] type NUMBER = U69;` or you can do the following: +Suppose in different environments you want a different type-level integer, you can either use e.g. `#[cfg(production)] type NUMBER = U69;` or you can do the following: ```rust use typenum::{U69, assert_type_eq}; @@ -108,15 +108,20 @@ type E = pconst![env!("ENV_VAR");]; assert_type_eq!(E, P69); ``` +# Roadmap + +- [ ] Feature gate evaluation of mathematical expressions and reading from environment variables. +- [ ] Enable testing for Rust version 1.70. + # Vendored Crates ## [`rsc`](https://github.com/fivemoreminix/rsc/commit/67c4ddffbe45a30de0fd696c569de885bfd4e9b4) version 3.0.0 -Reasons for vendoring `src`. +Reasons for vendoring `rsc`. -1. As of 28 March 2024, there is a version 3.0.0 of the crate on the GitHub [repository](https://github.com/fivemoreminix/rsc/commit/67c4ddffbe45a30de0fd696c569de885bfd4e9b4) but without corresponding crate on `crates.io`. +1. As of 28 March 2024, there is a version 3.0.0 of the crate on the GitHub [repository](https://github.com/fivemoreminix/rsc/commit/67c4ddffbe45a30de0fd696c569de885bfd4e9b4) but without a corresponding crate on `crates.io`. 2. Easier to implement `Num` for `isize` with vendoring. -3. `typenum-needs a mathematical expression evaluator. +3. `typenum-const needs a mathematical expression evaluator. 4. Its [license](https://github.com/fivemoreminix/rsc/tree/67c4ddffbe45a30de0fd696c569de885bfd4e9b4?tab=readme-ov-file#license) allows for 'usage without attribution'. Anyway, `src/vendors/rsc/Cargo.toml.vendored` is the original `Cargo.toml` file found in the repository. 5. Thanks to [Luke Wilson](https://github.com/fivemoreminix). diff --git a/src/lib.rs b/src/lib.rs index 82623eb..5acc60c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,7 +171,7 @@ pub fn uconst(items: TokenStream) -> TokenStream { /// /// ## 3. Invoke by reading from an environment variable /// -/// Note: `env!(...)` is a macro-like invocation. The first parameter is mandatory and is the key of the environment variable that `uconst` will read. The second parameter is optional and is the file path of the `.env.*` file to read the environment variable from, e.g. `env!("ENV_VAR", "./.env.prod")`, `"ENV_VAR"` is the key to read the value from and `"./.env.prod"` is the file path relative to [`CARGO_MANIFEST_DIR`]. +/// Note: `env!(...)` is a macro-like invocation. The first parameter is mandatory and is the key of the environment variable that `tnconst` will read. The second parameter is optional and is the file path of the `.env.*` file to read the environment variable from, e.g. `env!("ENV_VAR", "./.env.prod")`, `"ENV_VAR"` is the key to read the value from and `"./.env.prod"` is the file path relative to [`CARGO_MANIFEST_DIR`]. /// /// ```rust /// use typenum::{U69, assert_type_eq};