Skip to content

Commit

Permalink
update mostly docs and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Mar 31, 2024
1 parent abeadad commit e8e3144
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: dtolnay/[email protected]

- 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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "typenum-consts"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["Jim Chng <[email protected]>"]
exclude = [
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<U84938493>` (by the way, `U84938493` does not exist in `typenum::consts`). The alternative is to type `PInt<Sum<Prod<Exp<, ...>, ...>, ...>, ...>` (which argubly takes a lot more time).
Assuming you want a type-level positive integer `84938493`, `tnconst![+84938493]` outputs directly `typenum::PInt<U84938493>` (by the way, `U84938493` does not exist in `typenum::consts`). The alternative is to type `PInt<Sum<Prod<Exp<..., ...>, ...>, ...>, ...>` (which argubly takes a lot more time).

Example:

Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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).

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit e8e3144

Please sign in to comment.