Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b990542

Browse files
authoredMar 25, 2024
Merge pull request #1875 from Kobzol/benchmark-typenum
Add `typenum-1.17.0` benchmark
2 parents c836192 + f2941e9 commit b990542

30 files changed

+16104
-0
lines changed
 

‎collector/compile-benchmarks/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ They mostly consist of real-world crates.
5353
built with `--features=stm32f410` to have faster benchmarking times.
5454
- **syn-1.0.89**: A library for parsing Rust code. An important part of the Rust
5555
ecosystem.
56+
- **typenum-1.17.0**: A library that encodes integer computation within the trait system. Serves as
57+
a stress test for the trait solver, but at the same time it is also a very popular crate.
5658
- **unicode-normalization-0.1.19**: Unicode character composition and decomposition
5759
utilities. Uses huge `match` statements that stress the compiler in unusual
5860
ways.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"git": {
3+
"sha1": "b237efbb1da9646435274f63d7290cb7651b031f"
4+
},
5+
"path_in_vcs": ""
6+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request:
6+
branches:
7+
- main
8+
9+
name: CI
10+
11+
jobs:
12+
all-succeeded:
13+
name: All Succeeded
14+
if: always()
15+
runs-on: ubuntu-latest
16+
needs:
17+
- test-linux
18+
- test-non-linux
19+
- lint
20+
21+
steps:
22+
- name: Check if all jubs succeeded
23+
uses: re-actors/alls-green@release/v1
24+
with:
25+
jobs: ${{ toJSON(needs) }}
26+
27+
test-linux:
28+
name: Test Linux
29+
runs-on: ubuntu-latest
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
rust:
34+
- stable
35+
- beta
36+
- nightly
37+
mb_const_generics:
38+
- ""
39+
- "--features const-generics"
40+
target:
41+
- x86_64
42+
- i686
43+
- sparc64
44+
include:
45+
- mb_const_generics: ""
46+
rust: 1.37.0
47+
target: x86_64
48+
steps:
49+
- uses: actions/checkout@v3
50+
- uses: dtolnay/rust-toolchain@master
51+
with:
52+
toolchain: ${{ matrix.rust }}
53+
- uses: actions-rs/cargo@v1
54+
with:
55+
use-cross: ${{ matrix.target != 'x86_64' }}
56+
command: test
57+
args: --verbose --features "strict" ${{ matrix.mb_const_generics }} --target ${{ matrix.target }}-unknown-linux-gnu
58+
- uses: actions-rs/cargo@v1
59+
with:
60+
use-cross: ${{ matrix.target != 'x86_64' }}
61+
command: doc
62+
args: --features "strict" ${{ matrix.mb_const_generics }} --target ${{ matrix.target }}-unknown-linux-gnu
63+
64+
test-non-linux:
65+
name: Test non-Linux
66+
runs-on: ${{ matrix.os }}
67+
strategy:
68+
matrix:
69+
os:
70+
- macos-latest
71+
- windows-latest
72+
rust:
73+
- stable
74+
mb_const_generics:
75+
- ""
76+
- "--features const-generics"
77+
steps:
78+
- uses: actions/checkout@v3
79+
- uses: dtolnay/rust-toolchain@master
80+
with:
81+
toolchain: ${{ matrix.rust }}
82+
- run: cargo test --verbose --features "strict" ${{ matrix.mb_const_generics }}
83+
- run: cargo doc --features "strict" ${{ matrix.mb_const_generics }}
84+
85+
lint:
86+
name: Lint
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v3
90+
- uses: dtolnay/rust-toolchain@nightly
91+
with:
92+
components: rustfmt, clippy
93+
- run: cargo fmt --all -- --check
94+
- run: cargo clippy -- -D warnings
95+
# Allow deprecated because we test the no_std feature.
96+
- run: cargo clippy --all-features -- -D warnings -A deprecated
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on:
2+
push:
3+
tags:
4+
- 'v*'
5+
6+
name: Publish
7+
8+
jobs:
9+
release:
10+
name: GitHub Release
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- uses: marvinpinto/action-automatic-releases@latest
15+
with:
16+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
17+
prerelease: false
18+
19+
publish:
20+
name: Crates.io Publish
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: dtolnay/rust-toolchain@stable
25+
- uses: katyo/publish-crates@v1
26+
with:
27+
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
target
2+
Cargo.lock
3+
4+
*.bk
5+
*\~
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
diff --git a/src/lib.rs b/src/lib.rs
2+
index 7a40b2a0..1992946c 100644
3+
--- a/src/lib.rs
4+
+++ b/src/lib.rs
5+
@@ -196,3 +196,4 @@ mod sealed {
6+
impl Sealed for ATerm {}
7+
impl<V, A> Sealed for TArr<V, A> {}
8+
}
9+
+fn foo() { let a = 5; }
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Changelog
2+
3+
This project follows semantic versioning.
4+
5+
The MSRV (Minimum Supported Rust Version) is 1.37.0, and typenum is tested
6+
against this Rust version.
7+
8+
### Unreleased
9+
- [removed] Remove `force_unix_path_separator` feature, make it the default
10+
- [added] docs.rs metadata and cfg options
11+
- [added] Playground metadata
12+
13+
### 1.16.0 (2022-12-05)
14+
- [added] `const INT` field to the `ToInt` trait.
15+
- [added] `const-generics` field with `U<N>` mapping where `N` is a const generic.
16+
17+
### 1.15.0 (2021-12-25)
18+
- [fixed] Cross-compilation issue due to doing math in build script. (PR #177)
19+
- [added] New feature `scale_info` for using inside
20+
[Substrate](https://github.com/paritytech/substrate.git)-based runtimes (PR
21+
#175)
22+
23+
### 1.14.0 (2021-09-01)
24+
- [changed] Sealed all marker traits. Documentation already stated that these
25+
should not be implemented outside the crate, so this is not considered a
26+
breaking change.
27+
28+
### 1.13.0 (2021-03-12)
29+
- [changed] MSRV from 1.22.0 to 1.37.0.
30+
- [fixed] `op` macro with 2018 edition import.
31+
- [changed] Allowed calling `assert_type_eq` and `assert_type` at top level.
32+
- [added] Marker trait `Zero` for `Z0`, `U0`, and `B0`.
33+
- [added] Implementation of `Pow` trait for f32 and f64 with negative exponent.
34+
- [added] Trait `ToInt`.
35+
36+
### 1.12.0 (2020-04-13)
37+
- [added] Feature `force_unix_path_separator` to support building without Cargo.
38+
- [added] Greatest common divisor operator `Gcd` with alias `Gcf`.
39+
- [added] `gcd` to the `op!` macro.
40+
- [changed] Added `Copy` bound to `Rhs` of `Mul<Rhs>` impl for `<TArr<V, A>`.
41+
- [changed] Added `Copy` bound to `Rhs` of `Div<Rhs>` impl for `<TArr<V, A>`.
42+
- [changed] Added `Copy` bound to `Rhs` of `PartialDiv<Rhs>` impl for `<TArr<V, A>`.
43+
- [changed] Added `Copy` bound to `Rhs` of `Rem<Rhs>` impl for `<TArr<V, A>`.
44+
- [fixed] Make all functions #[inline].
45+
46+
### 1.11.2 (2019-08-26)
47+
- [fixed] Cross compilation from Linux to Windows.
48+
49+
### 1.11.1 (2019-08-25)
50+
- [fixed] Builds on earlier Rust builds again and added Rust 1.22.0 to Travis to
51+
prevent future breakage.
52+
53+
### 1.11.0 (2019-08-25)
54+
- [added] Integer `log2` to the `op!` macro.
55+
- [added] Integer binary logarithm operator `Logarithm2` with alias `Log2`.
56+
- [changed] Removed `feature(i128_type)` when running with the `i128`
57+
feature. Kept the feature flag. for typenum to maintain compatibility with
58+
old Rust versions.
59+
- [added] Integer `sqrt` to the `op!` macro.
60+
- [added] Integer square root operator `SquareRoot` with alias `Sqrt`.
61+
- [fixed] Bug with attempting to create U1024 type alias twice.
62+
63+
### 1.10.0 (2018-03-11)
64+
- [added] The `PowerOfTwo` marker trait.
65+
- [added] Associated constants for `Bit`, `Unsigned`, and `Integer`.
66+
67+
### 1.9.0 (2017-05-14)
68+
- [added] The `Abs` type operator and corresponding `AbsVal` alias.
69+
- [added] The feature `i128` that enables creating 128-bit integers from
70+
typenums.
71+
- [added] The `assert_type!` and `assert_type_eq!` macros.
72+
- [added] Operators to the `op!` macro, including those performed by `cmp!`.
73+
- [fixed] Bug in `op!` macro involving functions and convoluted expressions.
74+
- [deprecated] The `cmp!` macro.
75+
76+
### 1.8.0 (2017-04-12)
77+
- [added] The `op!` macro for conveniently performing type-level operations.
78+
- [added] The `cmp!` macro for conveniently performing type-level comparisons.
79+
- [added] Some comparison type-operators that are used by the `cmp!` macro.
80+
81+
### 1.7.0 (2017-03-24)
82+
- [added] Type operators `Min` and `Max` with accompanying aliases `Minimum` and
83+
`Maximum`
84+
85+
### 1.6.0 (2017-02-24)
86+
- [fixed] Bug in `Array` division.
87+
- [fixed] Bug where `Rem` would sometimes exit early with the wrong answer.
88+
- [added] `PartialDiv` operator that performs division as a partial function --
89+
it's defined only when there is no remainder.
90+
91+
### 1.5.2 (2017-02-04)
92+
- [fixed] Bug between `Div` implementation and type system.
93+
94+
### 1.5.1 (2016-11-08)
95+
- [fixed] Expanded implementation of `Pow` for primitives.
96+
97+
### 1.5.0 (2016-11-03)
98+
- [added] Functions to the `Pow` and `Len` traits. This is *technically* a
99+
breaking change, but it would only break someone's code if they have a custom
100+
impl for `Pow`. I would be very surprised if that is anyone other than me.
101+
102+
### 1.4.0 (2016-10-29)
103+
- [added] Type-level arrays of type-level integers. (PR #66)
104+
- [added] The types in this crate are now instantiable. (Issue #67, PR #68)
105+
106+
### 1.3.1 (2016-03-31)
107+
- [fixed] Bug with recent nightlies.
108+
109+
### 1.3.0 (2016-02-07)
110+
- [changed] Removed dependency on libstd. (Issue #53, PR #55)
111+
- [changed] Reorganized module structure. (PR #57)
112+
113+
### 1.2.0 (2016-01-03)
114+
- [added] This change log!
115+
- [added] Convenience type aliases for operators. (Issue #48, PR #50)
116+
- [added] Types in this crate now derive all possible traits. (Issue #42, PR
117+
#51)

‎collector/compile-benchmarks/typenum-1.17.0/Cargo.lock

Lines changed: 203 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
2+
#
3+
# When uploading crates to the registry Cargo will automatically
4+
# "normalize" Cargo.toml files for maximal compatibility
5+
# with all versions of Cargo and also rewrite `path` dependencies
6+
# to registry (e.g., crates.io) dependencies.
7+
#
8+
# If you are reading this file be aware that the original Cargo.toml
9+
# will likely look very different (and much more reasonable).
10+
# See Cargo.toml.orig for the original contents.
11+
12+
[package]
13+
edition = "2018"
14+
rust-version = "1.37.0"
15+
name = "typenum"
16+
version = "1.17.0"
17+
authors = [
18+
"Paho Lurie-Gregg <paho@paholg.com>",
19+
"Andre Bogus <bogusandre@gmail.com>",
20+
]
21+
description = """
22+
Typenum is a Rust library for type-level numbers evaluated at
23+
compile time. It currently supports bits, unsigned integers, and signed
24+
integers. It also provides a type-level array of type-level numbers, but its
25+
implementation is incomplete."""
26+
documentation = "https://docs.rs/typenum"
27+
readme = "README.md"
28+
categories = ["no-std"]
29+
license = "MIT OR Apache-2.0"
30+
repository = "https://github.com/paholg/typenum"
31+
32+
[package.metadata.docs.rs]
33+
features = [
34+
"i128",
35+
"const-generics",
36+
]
37+
rustdoc-args = [
38+
"--cfg",
39+
"docsrs",
40+
]
41+
42+
[package.metadata.playground]
43+
features = [
44+
"i128",
45+
"const-generics",
46+
]
47+
48+
[lib]
49+
name = "typenum"
50+
51+
[dependencies.scale-info]
52+
version = "1.0"
53+
optional = true
54+
default-features = false
55+
56+
[features]
57+
const-generics = []
58+
force_unix_path_separator = []
59+
i128 = []
60+
no_std = []
61+
scale_info = ["scale-info/derive"]
62+
strict = []
63+
64+
[workspace]

‎collector/compile-benchmarks/typenum-1.17.0/Cargo.toml.orig

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MIT OR Apache-2.0
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
1. Definitions.
8+
9+
"License" shall mean the terms and conditions for use, reproduction,
10+
and distribution as defined by Sections 1 through 9 of this document.
11+
12+
"Licensor" shall mean the copyright owner or entity authorized by
13+
the copyright owner that is granting the License.
14+
15+
"Legal Entity" shall mean the union of the acting entity and all
16+
other entities that control, are controlled by, or are under common
17+
control with that entity. For the purposes of this definition,
18+
"control" means (i) the power, direct or indirect, to cause the
19+
direction or management of such entity, whether by contract or
20+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
21+
outstanding shares, or (iii) beneficial ownership of such entity.
22+
23+
"You" (or "Your") shall mean an individual or Legal Entity
24+
exercising permissions granted by this License.
25+
26+
"Source" form shall mean the preferred form for making modifications,
27+
including but not limited to software source code, documentation
28+
source, and configuration files.
29+
30+
"Object" form shall mean any form resulting from mechanical
31+
transformation or translation of a Source form, including but
32+
not limited to compiled object code, generated documentation,
33+
and conversions to other media types.
34+
35+
"Work" shall mean the work of authorship, whether in Source or
36+
Object form, made available under the License, as indicated by a
37+
copyright notice that is included in or attached to the work
38+
(an example is provided in the Appendix below).
39+
40+
"Derivative Works" shall mean any work, whether in Source or Object
41+
form, that is based on (or derived from) the Work and for which the
42+
editorial revisions, annotations, elaborations, or other modifications
43+
represent, as a whole, an original work of authorship. For the purposes
44+
of this License, Derivative Works shall not include works that remain
45+
separable from, or merely link (or bind by name) to the interfaces of,
46+
the Work and Derivative Works thereof.
47+
48+
"Contribution" shall mean any work of authorship, including
49+
the original version of the Work and any modifications or additions
50+
to that Work or Derivative Works thereof, that is intentionally
51+
submitted to Licensor for inclusion in the Work by the copyright owner
52+
or by an individual or Legal Entity authorized to submit on behalf of
53+
the copyright owner. For the purposes of this definition, "submitted"
54+
means any form of electronic, verbal, or written communication sent
55+
to the Licensor or its representatives, including but not limited to
56+
communication on electronic mailing lists, source code control systems,
57+
and issue tracking systems that are managed by, or on behalf of, the
58+
Licensor for the purpose of discussing and improving the Work, but
59+
excluding communication that is conspicuously marked or otherwise
60+
designated in writing by the copyright owner as "Not a Contribution."
61+
62+
"Contributor" shall mean Licensor and any individual or Legal Entity
63+
on behalf of whom a Contribution has been received by Licensor and
64+
subsequently incorporated within the Work.
65+
66+
2. Grant of Copyright License. Subject to the terms and conditions of
67+
this License, each Contributor hereby grants to You a perpetual,
68+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69+
copyright license to reproduce, prepare Derivative Works of,
70+
publicly display, publicly perform, sublicense, and distribute the
71+
Work and such Derivative Works in Source or Object form.
72+
73+
3. Grant of Patent License. Subject to the terms and conditions of
74+
this License, each Contributor hereby grants to You a perpetual,
75+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76+
(except as stated in this section) patent license to make, have made,
77+
use, offer to sell, sell, import, and otherwise transfer the Work,
78+
where such license applies only to those patent claims licensable
79+
by such Contributor that are necessarily infringed by their
80+
Contribution(s) alone or by combination of their Contribution(s)
81+
with the Work to which such Contribution(s) was submitted. If You
82+
institute patent litigation against any entity (including a
83+
cross-claim or counterclaim in a lawsuit) alleging that the Work
84+
or a Contribution incorporated within the Work constitutes direct
85+
or contributory patent infringement, then any patent licenses
86+
granted to You under this License for that Work shall terminate
87+
as of the date such litigation is filed.
88+
89+
4. Redistribution. You may reproduce and distribute copies of the
90+
Work or Derivative Works thereof in any medium, with or without
91+
modifications, and in Source or Object form, provided that You
92+
meet the following conditions:
93+
94+
(a) You must give any other recipients of the Work or
95+
Derivative Works a copy of this License; and
96+
97+
(b) You must cause any modified files to carry prominent notices
98+
stating that You changed the files; and
99+
100+
(c) You must retain, in the Source form of any Derivative Works
101+
that You distribute, all copyright, patent, trademark, and
102+
attribution notices from the Source form of the Work,
103+
excluding those notices that do not pertain to any part of
104+
the Derivative Works; and
105+
106+
(d) If the Work includes a "NOTICE" text file as part of its
107+
distribution, then any Derivative Works that You distribute must
108+
include a readable copy of the attribution notices contained
109+
within such NOTICE file, excluding those notices that do not
110+
pertain to any part of the Derivative Works, in at least one
111+
of the following places: within a NOTICE text file distributed
112+
as part of the Derivative Works; within the Source form or
113+
documentation, if provided along with the Derivative Works; or,
114+
within a display generated by the Derivative Works, if and
115+
wherever such third-party notices normally appear. The contents
116+
of the NOTICE file are for informational purposes only and
117+
do not modify the License. You may add Your own attribution
118+
notices within Derivative Works that You distribute, alongside
119+
or as an addendum to the NOTICE text from the Work, provided
120+
that such additional attribution notices cannot be construed
121+
as modifying the License.
122+
123+
You may add Your own copyright statement to Your modifications and
124+
may provide additional or different license terms and conditions
125+
for use, reproduction, or distribution of Your modifications, or
126+
for any such Derivative Works as a whole, provided Your use,
127+
reproduction, and distribution of the Work otherwise complies with
128+
the conditions stated in this License.
129+
130+
5. Submission of Contributions. Unless You explicitly state otherwise,
131+
any Contribution intentionally submitted for inclusion in the Work
132+
by You to the Licensor shall be under the terms and conditions of
133+
this License, without any additional terms or conditions.
134+
Notwithstanding the above, nothing herein shall supersede or modify
135+
the terms of any separate license agreement you may have executed
136+
with Licensor regarding such Contributions.
137+
138+
6. Trademarks. This License does not grant permission to use the trade
139+
names, trademarks, service marks, or product names of the Licensor,
140+
except as required for reasonable and customary use in describing the
141+
origin of the Work and reproducing the content of the NOTICE file.
142+
143+
7. Disclaimer of Warranty. Unless required by applicable law or
144+
agreed to in writing, Licensor provides the Work (and each
145+
Contributor provides its Contributions) on an "AS IS" BASIS,
146+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147+
implied, including, without limitation, any warranties or conditions
148+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149+
PARTICULAR PURPOSE. You are solely responsible for determining the
150+
appropriateness of using or redistributing the Work and assume any
151+
risks associated with Your exercise of permissions under this License.
152+
153+
8. Limitation of Liability. In no event and under no legal theory,
154+
whether in tort (including negligence), contract, or otherwise,
155+
unless required by applicable law (such as deliberate and grossly
156+
negligent acts) or agreed to in writing, shall any Contributor be
157+
liable to You for damages, including any direct, indirect, special,
158+
incidental, or consequential damages of any character arising as a
159+
result of this License or out of the use or inability to use the
160+
Work (including but not limited to damages for loss of goodwill,
161+
work stoppage, computer failure or malfunction, or any and all
162+
other commercial damages or losses), even if such Contributor
163+
has been advised of the possibility of such damages.
164+
165+
9. Accepting Warranty or Additional Liability. While redistributing
166+
the Work or Derivative Works thereof, You may choose to offer,
167+
and charge a fee for, acceptance of support, warranty, indemnity,
168+
or other liability obligations and/or rights consistent with this
169+
License. However, in accepting such obligations, You may act only
170+
on Your own behalf and on Your sole responsibility, not on behalf
171+
of any other Contributor, and only if You agree to indemnify,
172+
defend, and hold each Contributor harmless for any liability
173+
incurred by, or claims asserted against, such Contributor by reason
174+
of your accepting any such warranty or additional liability.
175+
176+
END OF TERMS AND CONDITIONS
177+
178+
APPENDIX: How to apply the Apache License to your work.
179+
180+
To apply the Apache License to your work, attach the following
181+
boilerplate notice, with the fields enclosed by brackets "[]"
182+
replaced with your own identifying information. (Don't include
183+
the brackets!) The text should be enclosed in the appropriate
184+
comment syntax for the file format. We also recommend that a
185+
file or class name and description of purpose be included on the
186+
same "printed page" as the copyright notice for easier
187+
identification within third-party archives.
188+
189+
Copyright 2014 Paho Lurie-Gregg
190+
191+
Licensed under the Apache License, Version 2.0 (the "License");
192+
you may not use this file except in compliance with the License.
193+
You may obtain a copy of the License at
194+
195+
http://www.apache.org/licenses/LICENSE-2.0
196+
197+
Unless required by applicable law or agreed to in writing, software
198+
distributed under the License is distributed on an "AS IS" BASIS,
199+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200+
See the License for the specific language governing permissions and
201+
limitations under the License.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Paho Lurie-Gregg
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[![crates.io](https://img.shields.io/crates/v/typenum.svg)](https://crates.io/crates/typenum)
2+
[![Build Status](https://github.com/paholg/typenum/actions/workflows/check.yml/badge.svg)](https://github.com/paholg/typenum/actions/workflows/check.yml)
3+
4+
Typenum
5+
=====
6+
7+
Typenum is a Rust library for type-level numbers evaluated at compile time. It
8+
currently supports bits, unsigned integers, and signed integers.
9+
10+
Typenum depends only on libcore, and so is suitable for use on any platform!
11+
12+
For the full documentation, go [here](https://docs.rs/typenum).
13+
14+
### Importing
15+
16+
While `typenum` is divided into several modules, they are all re-exported
17+
through the crate root, so you can import anything contained herein with `use
18+
typenum::whatever;`, ignoring the crate structure.
19+
20+
You may also find it useful to treat the `consts` module as a prelude,
21+
performing a glob import.
22+
23+
### Example
24+
25+
Here is a trivial example of `typenum`'s use:
26+
27+
```rust
28+
use typenum::{Sum, Exp, Integer, N2, P3, P4};
29+
30+
type X = Sum<P3, P4>;
31+
assert_eq!(<X as Integer>::to_i32(), 7);
32+
33+
type Y = Exp<N2, P3>;
34+
assert_eq!(<Y as Integer>::to_i32(), -8);
35+
```
36+
37+
For a non-trivial example of its use, see one of the crates that depends on
38+
it. The full list is
39+
[here](https://crates.io/crates/typenum/reverse_dependencies). Of note are
40+
[dimensioned](https://crates.io/crates/dimensioned/) which does compile-time
41+
type checking for arbitrary unit systems and
42+
[generic-array](https://crates.io/crates/generic-array/) which provides arrays
43+
whose length you can generically refer to.
44+
45+
### Error messages
46+
47+
48+
Typenum's error messages aren't great, and can be difficult to parse. The good
49+
news is that the fine folks at Auxon have written a tool to help with it. Please
50+
take a look at [tnfilt](https://github.com/auxoncorp/tnfilt).
51+
52+
### License
53+
54+
Licensed under either of
55+
56+
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
57+
http://www.apache.org/licenses/LICENSE-2.0)
58+
* MIT license
59+
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
60+
61+
at your option.
62+
63+
### Contribution
64+
65+
Unless you explicitly state otherwise, any contribution intentionally submitted
66+
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
67+
dual licensed as above, without any additional terms or conditions.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cognitive-complexity-threshold=35
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cargo_opts": "--features=i128,const-generics",
3+
"artifact": "library",
4+
"category": "primary"
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
format_code_in_doc_comments = true
Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
//! A type-level array of type-level numbers.
2+
//!
3+
//! It is not very featureful right now, and should be considered a work in progress.
4+
5+
use core::ops::{Add, Div, Mul, Sub};
6+
7+
use super::*;
8+
9+
/// The terminating type for type arrays.
10+
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug)]
11+
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
12+
pub struct ATerm;
13+
14+
impl TypeArray for ATerm {}
15+
16+
/// `TArr` is a type that acts as an array of types. It is defined similarly to `UInt`, only its
17+
/// values can be more than bits, and it is designed to act as an array. So you can only add two if
18+
/// they have the same number of elements, for example.
19+
///
20+
/// This array is only really designed to contain `Integer` types. If you use it with others, you
21+
/// may find it lacking functionality.
22+
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug)]
23+
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
24+
pub struct TArr<V, A> {
25+
first: V,
26+
rest: A,
27+
}
28+
29+
impl<V, A> TypeArray for TArr<V, A> {}
30+
31+
/// Create a new type-level array. Only usable on Rust 1.13.0 or newer.
32+
///
33+
/// There's not a whole lot you can do with it right now.
34+
///
35+
/// # Example
36+
/// ```rust
37+
/// #[macro_use]
38+
/// extern crate typenum;
39+
/// use typenum::consts::*;
40+
///
41+
/// type Array = tarr![P3, N4, Z0, P38];
42+
/// # fn main() { let _: Array; }
43+
#[macro_export]
44+
macro_rules! tarr {
45+
() => ( $crate::ATerm );
46+
($n:ty) => ( $crate::TArr<$n, $crate::ATerm> );
47+
($n:ty,) => ( $crate::TArr<$n, $crate::ATerm> );
48+
($n:ty, $($tail:ty),+) => ( $crate::TArr<$n, tarr![$($tail),+]> );
49+
($n:ty, $($tail:ty),+,) => ( $crate::TArr<$n, tarr![$($tail),+]> );
50+
}
51+
52+
// ---------------------------------------------------------------------------------------
53+
// Length
54+
55+
/// Length of `ATerm` by itself is 0
56+
impl Len for ATerm {
57+
type Output = U0;
58+
#[inline]
59+
fn len(&self) -> Self::Output {
60+
UTerm
61+
}
62+
}
63+
64+
/// Size of a `TypeArray`
65+
impl<V, A> Len for TArr<V, A>
66+
where
67+
A: Len,
68+
Length<A>: Add<B1>,
69+
Sum<Length<A>, B1>: Unsigned,
70+
{
71+
type Output = Add1<Length<A>>;
72+
#[inline]
73+
fn len(&self) -> Self::Output {
74+
self.rest.len() + B1
75+
}
76+
}
77+
78+
// ---------------------------------------------------------------------------------------
79+
// Add arrays
80+
// Note that two arrays are only addable if they are the same length.
81+
82+
impl Add<ATerm> for ATerm {
83+
type Output = ATerm;
84+
#[inline]
85+
fn add(self, _: ATerm) -> Self::Output {
86+
ATerm
87+
}
88+
}
89+
90+
impl<Al, Vl, Ar, Vr> Add<TArr<Vr, Ar>> for TArr<Vl, Al>
91+
where
92+
Al: Add<Ar>,
93+
Vl: Add<Vr>,
94+
{
95+
type Output = TArr<Sum<Vl, Vr>, Sum<Al, Ar>>;
96+
#[inline]
97+
fn add(self, rhs: TArr<Vr, Ar>) -> Self::Output {
98+
TArr {
99+
first: self.first + rhs.first,
100+
rest: self.rest + rhs.rest,
101+
}
102+
}
103+
}
104+
105+
// ---------------------------------------------------------------------------------------
106+
// Subtract arrays
107+
// Note that two arrays are only subtractable if they are the same length.
108+
109+
impl Sub<ATerm> for ATerm {
110+
type Output = ATerm;
111+
#[inline]
112+
fn sub(self, _: ATerm) -> Self::Output {
113+
ATerm
114+
}
115+
}
116+
117+
impl<Vl, Al, Vr, Ar> Sub<TArr<Vr, Ar>> for TArr<Vl, Al>
118+
where
119+
Vl: Sub<Vr>,
120+
Al: Sub<Ar>,
121+
{
122+
type Output = TArr<Diff<Vl, Vr>, Diff<Al, Ar>>;
123+
#[inline]
124+
fn sub(self, rhs: TArr<Vr, Ar>) -> Self::Output {
125+
TArr {
126+
first: self.first - rhs.first,
127+
rest: self.rest - rhs.rest,
128+
}
129+
}
130+
}
131+
132+
// ---------------------------------------------------------------------------------------
133+
// Multiply an array by a scalar
134+
135+
impl<Rhs> Mul<Rhs> for ATerm {
136+
type Output = ATerm;
137+
#[inline]
138+
fn mul(self, _: Rhs) -> Self::Output {
139+
ATerm
140+
}
141+
}
142+
143+
impl<V, A, Rhs> Mul<Rhs> for TArr<V, A>
144+
where
145+
V: Mul<Rhs>,
146+
A: Mul<Rhs>,
147+
Rhs: Copy,
148+
{
149+
type Output = TArr<Prod<V, Rhs>, Prod<A, Rhs>>;
150+
#[inline]
151+
fn mul(self, rhs: Rhs) -> Self::Output {
152+
TArr {
153+
first: self.first * rhs,
154+
rest: self.rest * rhs,
155+
}
156+
}
157+
}
158+
159+
impl Mul<ATerm> for Z0 {
160+
type Output = ATerm;
161+
#[inline]
162+
fn mul(self, _: ATerm) -> Self::Output {
163+
ATerm
164+
}
165+
}
166+
167+
impl<U> Mul<ATerm> for PInt<U>
168+
where
169+
U: Unsigned + NonZero,
170+
{
171+
type Output = ATerm;
172+
#[inline]
173+
fn mul(self, _: ATerm) -> Self::Output {
174+
ATerm
175+
}
176+
}
177+
178+
impl<U> Mul<ATerm> for NInt<U>
179+
where
180+
U: Unsigned + NonZero,
181+
{
182+
type Output = ATerm;
183+
#[inline]
184+
fn mul(self, _: ATerm) -> Self::Output {
185+
ATerm
186+
}
187+
}
188+
189+
impl<V, A> Mul<TArr<V, A>> for Z0
190+
where
191+
Z0: Mul<A>,
192+
{
193+
type Output = TArr<Z0, Prod<Z0, A>>;
194+
#[inline]
195+
fn mul(self, rhs: TArr<V, A>) -> Self::Output {
196+
TArr {
197+
first: Z0,
198+
rest: self * rhs.rest,
199+
}
200+
}
201+
}
202+
203+
impl<V, A, U> Mul<TArr<V, A>> for PInt<U>
204+
where
205+
U: Unsigned + NonZero,
206+
PInt<U>: Mul<A> + Mul<V>,
207+
{
208+
type Output = TArr<Prod<PInt<U>, V>, Prod<PInt<U>, A>>;
209+
#[inline]
210+
fn mul(self, rhs: TArr<V, A>) -> Self::Output {
211+
TArr {
212+
first: self * rhs.first,
213+
rest: self * rhs.rest,
214+
}
215+
}
216+
}
217+
218+
impl<V, A, U> Mul<TArr<V, A>> for NInt<U>
219+
where
220+
U: Unsigned + NonZero,
221+
NInt<U>: Mul<A> + Mul<V>,
222+
{
223+
type Output = TArr<Prod<NInt<U>, V>, Prod<NInt<U>, A>>;
224+
#[inline]
225+
fn mul(self, rhs: TArr<V, A>) -> Self::Output {
226+
TArr {
227+
first: self * rhs.first,
228+
rest: self * rhs.rest,
229+
}
230+
}
231+
}
232+
233+
// ---------------------------------------------------------------------------------------
234+
// Divide an array by a scalar
235+
236+
impl<Rhs> Div<Rhs> for ATerm {
237+
type Output = ATerm;
238+
#[inline]
239+
fn div(self, _: Rhs) -> Self::Output {
240+
ATerm
241+
}
242+
}
243+
244+
impl<V, A, Rhs> Div<Rhs> for TArr<V, A>
245+
where
246+
V: Div<Rhs>,
247+
A: Div<Rhs>,
248+
Rhs: Copy,
249+
{
250+
type Output = TArr<Quot<V, Rhs>, Quot<A, Rhs>>;
251+
#[inline]
252+
fn div(self, rhs: Rhs) -> Self::Output {
253+
TArr {
254+
first: self.first / rhs,
255+
rest: self.rest / rhs,
256+
}
257+
}
258+
}
259+
260+
// ---------------------------------------------------------------------------------------
261+
// Partial Divide an array by a scalar
262+
263+
impl<Rhs> PartialDiv<Rhs> for ATerm {
264+
type Output = ATerm;
265+
#[inline]
266+
fn partial_div(self, _: Rhs) -> Self::Output {
267+
ATerm
268+
}
269+
}
270+
271+
impl<V, A, Rhs> PartialDiv<Rhs> for TArr<V, A>
272+
where
273+
V: PartialDiv<Rhs>,
274+
A: PartialDiv<Rhs>,
275+
Rhs: Copy,
276+
{
277+
type Output = TArr<PartialQuot<V, Rhs>, PartialQuot<A, Rhs>>;
278+
#[inline]
279+
fn partial_div(self, rhs: Rhs) -> Self::Output {
280+
TArr {
281+
first: self.first.partial_div(rhs),
282+
rest: self.rest.partial_div(rhs),
283+
}
284+
}
285+
}
286+
287+
// ---------------------------------------------------------------------------------------
288+
// Modulo an array by a scalar
289+
use core::ops::Rem;
290+
291+
impl<Rhs> Rem<Rhs> for ATerm {
292+
type Output = ATerm;
293+
#[inline]
294+
fn rem(self, _: Rhs) -> Self::Output {
295+
ATerm
296+
}
297+
}
298+
299+
impl<V, A, Rhs> Rem<Rhs> for TArr<V, A>
300+
where
301+
V: Rem<Rhs>,
302+
A: Rem<Rhs>,
303+
Rhs: Copy,
304+
{
305+
type Output = TArr<Mod<V, Rhs>, Mod<A, Rhs>>;
306+
#[inline]
307+
fn rem(self, rhs: Rhs) -> Self::Output {
308+
TArr {
309+
first: self.first % rhs,
310+
rest: self.rest % rhs,
311+
}
312+
}
313+
}
314+
315+
// ---------------------------------------------------------------------------------------
316+
// Negate an array
317+
use core::ops::Neg;
318+
319+
impl Neg for ATerm {
320+
type Output = ATerm;
321+
#[inline]
322+
fn neg(self) -> Self::Output {
323+
ATerm
324+
}
325+
}
326+
327+
impl<V, A> Neg for TArr<V, A>
328+
where
329+
V: Neg,
330+
A: Neg,
331+
{
332+
type Output = TArr<Negate<V>, Negate<A>>;
333+
#[inline]
334+
fn neg(self) -> Self::Output {
335+
TArr {
336+
first: -self.first,
337+
rest: -self.rest,
338+
}
339+
}
340+
}
Lines changed: 337 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,337 @@
1+
//! Type-level bits.
2+
//!
3+
//! These are rather simple and are used as the building blocks of the
4+
//! other number types in this crate.
5+
//!
6+
//!
7+
//! **Type operators** implemented:
8+
//!
9+
//! - From `core::ops`: `BitAnd`, `BitOr`, `BitXor`, and `Not`.
10+
//! - From `typenum`: `Same` and `Cmp`.
11+
12+
use crate::{private::InternalMarker, Cmp, Equal, Greater, Less, NonZero, PowerOfTwo, Zero};
13+
use core::ops::{BitAnd, BitOr, BitXor, Not};
14+
15+
pub use crate::marker_traits::Bit;
16+
17+
/// The type-level bit 0.
18+
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
19+
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
20+
pub struct B0;
21+
22+
impl B0 {
23+
/// Instantiates a singleton representing this bit.
24+
#[inline]
25+
pub fn new() -> B0 {
26+
B0
27+
}
28+
}
29+
30+
/// The type-level bit 1.
31+
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
32+
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
33+
pub struct B1;
34+
35+
impl B1 {
36+
/// Instantiates a singleton representing this bit.
37+
#[inline]
38+
pub fn new() -> B1 {
39+
B1
40+
}
41+
}
42+
43+
impl Bit for B0 {
44+
const U8: u8 = 0;
45+
const BOOL: bool = false;
46+
47+
#[inline]
48+
fn new() -> Self {
49+
Self
50+
}
51+
#[inline]
52+
fn to_u8() -> u8 {
53+
0
54+
}
55+
#[inline]
56+
fn to_bool() -> bool {
57+
false
58+
}
59+
}
60+
61+
impl Bit for B1 {
62+
const U8: u8 = 1;
63+
const BOOL: bool = true;
64+
65+
#[inline]
66+
fn new() -> Self {
67+
Self
68+
}
69+
#[inline]
70+
fn to_u8() -> u8 {
71+
1
72+
}
73+
#[inline]
74+
fn to_bool() -> bool {
75+
true
76+
}
77+
}
78+
79+
impl Zero for B0 {}
80+
impl NonZero for B1 {}
81+
impl PowerOfTwo for B1 {}
82+
83+
/// Not of 0 (!0 = 1)
84+
impl Not for B0 {
85+
type Output = B1;
86+
#[inline]
87+
fn not(self) -> Self::Output {
88+
B1
89+
}
90+
}
91+
/// Not of 1 (!1 = 0)
92+
impl Not for B1 {
93+
type Output = B0;
94+
#[inline]
95+
fn not(self) -> Self::Output {
96+
B0
97+
}
98+
}
99+
100+
/// And with 0 ( 0 & B = 0)
101+
impl<Rhs: Bit> BitAnd<Rhs> for B0 {
102+
type Output = B0;
103+
#[inline]
104+
fn bitand(self, _: Rhs) -> Self::Output {
105+
B0
106+
}
107+
}
108+
109+
/// And with 1 ( 1 & 0 = 0)
110+
impl BitAnd<B0> for B1 {
111+
type Output = B0;
112+
#[inline]
113+
fn bitand(self, _: B0) -> Self::Output {
114+
B0
115+
}
116+
}
117+
118+
/// And with 1 ( 1 & 1 = 1)
119+
impl BitAnd<B1> for B1 {
120+
type Output = B1;
121+
#[inline]
122+
fn bitand(self, _: B1) -> Self::Output {
123+
B1
124+
}
125+
}
126+
127+
/// Or with 0 ( 0 | 0 = 0)
128+
impl BitOr<B0> for B0 {
129+
type Output = B0;
130+
#[inline]
131+
fn bitor(self, _: B0) -> Self::Output {
132+
B0
133+
}
134+
}
135+
136+
/// Or with 0 ( 0 | 1 = 1)
137+
impl BitOr<B1> for B0 {
138+
type Output = B1;
139+
#[inline]
140+
fn bitor(self, _: B1) -> Self::Output {
141+
B1
142+
}
143+
}
144+
145+
/// Or with 1 ( 1 | B = 1)
146+
impl<Rhs: Bit> BitOr<Rhs> for B1 {
147+
type Output = B1;
148+
#[inline]
149+
fn bitor(self, _: Rhs) -> Self::Output {
150+
B1
151+
}
152+
}
153+
154+
/// Xor between 0 and 0 ( 0 ^ 0 = 0)
155+
impl BitXor<B0> for B0 {
156+
type Output = B0;
157+
#[inline]
158+
fn bitxor(self, _: B0) -> Self::Output {
159+
B0
160+
}
161+
}
162+
/// Xor between 1 and 0 ( 1 ^ 0 = 1)
163+
impl BitXor<B0> for B1 {
164+
type Output = B1;
165+
#[inline]
166+
fn bitxor(self, _: B0) -> Self::Output {
167+
B1
168+
}
169+
}
170+
/// Xor between 0 and 1 ( 0 ^ 1 = 1)
171+
impl BitXor<B1> for B0 {
172+
type Output = B1;
173+
#[inline]
174+
fn bitxor(self, _: B1) -> Self::Output {
175+
B1
176+
}
177+
}
178+
/// Xor between 1 and 1 ( 1 ^ 1 = 0)
179+
impl BitXor<B1> for B1 {
180+
type Output = B0;
181+
#[inline]
182+
fn bitxor(self, _: B1) -> Self::Output {
183+
B0
184+
}
185+
}
186+
187+
#[cfg(tests)]
188+
mod tests {
189+
// macro for testing operation results. Uses `Same` to ensure the types are equal and
190+
// not just the values they evaluate to.
191+
macro_rules! test_bit_op {
192+
($op:ident $Lhs:ident = $Answer:ident) => {{
193+
type Test = <<$Lhs as $op>::Output as ::Same<$Answer>>::Output;
194+
assert_eq!(<$Answer as Bit>::to_u8(), <Test as Bit>::to_u8());
195+
}};
196+
($Lhs:ident $op:ident $Rhs:ident = $Answer:ident) => {{
197+
type Test = <<$Lhs as $op<$Rhs>>::Output as ::Same<$Answer>>::Output;
198+
assert_eq!(<$Answer as Bit>::to_u8(), <Test as Bit>::to_u8());
199+
}};
200+
}
201+
202+
#[test]
203+
fn bit_operations() {
204+
test_bit_op!(Not B0 = B1);
205+
test_bit_op!(Not B1 = B0);
206+
207+
test_bit_op!(B0 BitAnd B0 = B0);
208+
test_bit_op!(B0 BitAnd B1 = B0);
209+
test_bit_op!(B1 BitAnd B0 = B0);
210+
test_bit_op!(B1 BitAnd B1 = B1);
211+
212+
test_bit_op!(B0 BitOr B0 = B0);
213+
test_bit_op!(B0 BitOr B1 = B1);
214+
test_bit_op!(B1 BitOr B0 = B1);
215+
test_bit_op!(B1 BitOr B1 = B1);
216+
217+
test_bit_op!(B0 BitXor B0 = B0);
218+
test_bit_op!(B0 BitXor B1 = B1);
219+
test_bit_op!(B1 BitXor B0 = B1);
220+
test_bit_op!(B1 BitXor B1 = B0);
221+
}
222+
}
223+
224+
impl Cmp<B0> for B0 {
225+
type Output = Equal;
226+
227+
#[inline]
228+
fn compare<P: InternalMarker>(&self, _: &B0) -> Self::Output {
229+
Equal
230+
}
231+
}
232+
233+
impl Cmp<B1> for B0 {
234+
type Output = Less;
235+
236+
#[inline]
237+
fn compare<P: InternalMarker>(&self, _: &B1) -> Self::Output {
238+
Less
239+
}
240+
}
241+
242+
impl Cmp<B0> for B1 {
243+
type Output = Greater;
244+
245+
#[inline]
246+
fn compare<P: InternalMarker>(&self, _: &B0) -> Self::Output {
247+
Greater
248+
}
249+
}
250+
251+
impl Cmp<B1> for B1 {
252+
type Output = Equal;
253+
254+
#[inline]
255+
fn compare<P: InternalMarker>(&self, _: &B1) -> Self::Output {
256+
Equal
257+
}
258+
}
259+
260+
use crate::Min;
261+
impl Min<B0> for B0 {
262+
type Output = B0;
263+
#[inline]
264+
fn min(self, _: B0) -> B0 {
265+
self
266+
}
267+
}
268+
impl Min<B1> for B0 {
269+
type Output = B0;
270+
#[inline]
271+
fn min(self, _: B1) -> B0 {
272+
self
273+
}
274+
}
275+
impl Min<B0> for B1 {
276+
type Output = B0;
277+
#[inline]
278+
fn min(self, rhs: B0) -> B0 {
279+
rhs
280+
}
281+
}
282+
impl Min<B1> for B1 {
283+
type Output = B1;
284+
#[inline]
285+
fn min(self, _: B1) -> B1 {
286+
self
287+
}
288+
}
289+
290+
use crate::Max;
291+
impl Max<B0> for B0 {
292+
type Output = B0;
293+
#[inline]
294+
fn max(self, _: B0) -> B0 {
295+
self
296+
}
297+
}
298+
impl Max<B1> for B0 {
299+
type Output = B1;
300+
#[inline]
301+
fn max(self, rhs: B1) -> B1 {
302+
rhs
303+
}
304+
}
305+
impl Max<B0> for B1 {
306+
type Output = B1;
307+
#[inline]
308+
fn max(self, _: B0) -> B1 {
309+
self
310+
}
311+
}
312+
impl Max<B1> for B1 {
313+
type Output = B1;
314+
#[inline]
315+
fn max(self, _: B1) -> B1 {
316+
self
317+
}
318+
}
319+
320+
#[cfg(test)]
321+
mod tests {
322+
#[test]
323+
fn bit_creation() {
324+
{
325+
use crate::{B0, B1};
326+
let _: B0 = B0::new();
327+
let _: B1 = B1::new();
328+
}
329+
330+
{
331+
use crate::{Bit, B0, B1};
332+
333+
let _: B0 = <B0 as Bit>::new();
334+
let _: B1 = <B1 as Bit>::new();
335+
}
336+
}
337+
}

‎collector/compile-benchmarks/typenum-1.17.0/src/generated/consts.rs

Lines changed: 2248 additions & 0 deletions
Large diffs are not rendered by default.

‎collector/compile-benchmarks/typenum-1.17.0/src/generated/generic_const_mappings.rs

Lines changed: 5531 additions & 0 deletions
Large diffs are not rendered by default.

‎collector/compile-benchmarks/typenum-1.17.0/src/generated/op.rs

Lines changed: 1030 additions & 0 deletions
Large diffs are not rendered by default.

‎collector/compile-benchmarks/typenum-1.17.0/src/int.rs

Lines changed: 1401 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
//! This crate provides type-level numbers evaluated at compile time. It depends only on libcore.
2+
//!
3+
//! The traits defined or used in this crate are used in a typical manner. They can be divided into
4+
//! two categories: **marker traits** and **type operators**.
5+
//!
6+
//! Many of the marker traits have functions defined, but they all do essentially the same thing:
7+
//! convert a type into its runtime counterpart, and are really just there for debugging. For
8+
//! example,
9+
//!
10+
//! ```rust
11+
//! use typenum::{Integer, N4};
12+
//!
13+
//! assert_eq!(N4::to_i32(), -4);
14+
//! ```
15+
//!
16+
//! **Type operators** are traits that behave as functions at the type level. These are the meat of
17+
//! this library. Where possible, traits defined in libcore have been used, but their attached
18+
//! functions have not been implemented.
19+
//!
20+
//! For example, the `Add` trait is implemented for both unsigned and signed integers, but the
21+
//! `add` function is not. As there are never any objects of the types defined here, it wouldn't
22+
//! make sense to implement it. What is important is its associated type `Output`, which is where
23+
//! the addition happens.
24+
//!
25+
//! ```rust
26+
//! use std::ops::Add;
27+
//! use typenum::{Integer, P3, P4};
28+
//!
29+
//! type X = <P3 as Add<P4>>::Output;
30+
//! assert_eq!(<X as Integer>::to_i32(), 7);
31+
//! ```
32+
//!
33+
//! In addition, helper aliases are defined for type operators. For example, the above snippet
34+
//! could be replaced with
35+
//!
36+
//! ```rust
37+
//! use typenum::{Integer, Sum, P3, P4};
38+
//!
39+
//! type X = Sum<P3, P4>;
40+
//! assert_eq!(<X as Integer>::to_i32(), 7);
41+
//! ```
42+
//!
43+
//! Documented in each module is the full list of type operators implemented.
44+
45+
#![no_std]
46+
#![forbid(unsafe_code)]
47+
#![warn(missing_docs)]
48+
#![cfg_attr(feature = "strict", deny(missing_docs))]
49+
#![cfg_attr(feature = "strict", deny(warnings))]
50+
#![cfg_attr(
51+
feature = "cargo-clippy",
52+
allow(
53+
clippy::len_without_is_empty,
54+
clippy::many_single_char_names,
55+
clippy::new_without_default,
56+
clippy::suspicious_arithmetic_impl,
57+
clippy::type_complexity,
58+
clippy::wrong_self_convention,
59+
)
60+
)]
61+
#![cfg_attr(feature = "cargo-clippy", deny(clippy::missing_inline_in_public_items))]
62+
#![doc(html_root_url = "https://docs.rs/typenum/1.17.0")]
63+
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg))]
64+
65+
// For debugging macros:
66+
// #![feature(trace_macros)]
67+
// trace_macros!(true);
68+
69+
use core::cmp::Ordering;
70+
71+
mod generated {
72+
// These files are normally generated by the build script of `typenum`.
73+
// But since rustc-perf doesn't really support build scripts, the build script was pre-executed
74+
// and its outputs were committed into the repository.
75+
include!("generated/op.rs");
76+
include!("generated/consts.rs");
77+
78+
#[cfg(feature = "const-generics")]
79+
include!("generated/generic_const_mappings.rs");
80+
}
81+
82+
pub mod bit;
83+
pub mod int;
84+
pub mod marker_traits;
85+
pub mod operator_aliases;
86+
pub mod private;
87+
pub mod type_operators;
88+
pub mod uint;
89+
90+
pub mod array;
91+
92+
pub use crate::{
93+
array::{ATerm, TArr},
94+
generated::consts,
95+
int::{NInt, PInt},
96+
marker_traits::*,
97+
operator_aliases::*,
98+
type_operators::*,
99+
uint::{UInt, UTerm},
100+
};
101+
102+
#[doc(no_inline)]
103+
#[rustfmt::skip]
104+
pub use consts::{
105+
False, True, B0, B1,
106+
U0, U1, U2, *,
107+
N1, N2, Z0, P1, P2, *,
108+
};
109+
110+
#[cfg(feature = "const-generics")]
111+
pub use crate::generated::generic_const_mappings;
112+
113+
#[cfg(feature = "const-generics")]
114+
#[doc(no_inline)]
115+
pub use generic_const_mappings::{Const, ToUInt, U};
116+
117+
/// A potential output from `Cmp`, this is the type equivalent to the enum variant
118+
/// `core::cmp::Ordering::Greater`.
119+
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
120+
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
121+
pub struct Greater;
122+
123+
/// A potential output from `Cmp`, this is the type equivalent to the enum variant
124+
/// `core::cmp::Ordering::Less`.
125+
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
126+
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
127+
pub struct Less;
128+
129+
/// A potential output from `Cmp`, this is the type equivalent to the enum variant
130+
/// `core::cmp::Ordering::Equal`.
131+
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
132+
#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
133+
pub struct Equal;
134+
135+
/// Returns `core::cmp::Ordering::Greater`
136+
impl Ord for Greater {
137+
#[inline]
138+
fn to_ordering() -> Ordering {
139+
Ordering::Greater
140+
}
141+
}
142+
143+
/// Returns `core::cmp::Ordering::Less`
144+
impl Ord for Less {
145+
#[inline]
146+
fn to_ordering() -> Ordering {
147+
Ordering::Less
148+
}
149+
}
150+
151+
/// Returns `core::cmp::Ordering::Equal`
152+
impl Ord for Equal {
153+
#[inline]
154+
fn to_ordering() -> Ordering {
155+
Ordering::Equal
156+
}
157+
}
158+
159+
/// Asserts that two types are the same.
160+
#[macro_export]
161+
macro_rules! assert_type_eq {
162+
($a:ty, $b:ty) => {
163+
const _: core::marker::PhantomData<<$a as $crate::Same<$b>>::Output> =
164+
core::marker::PhantomData;
165+
};
166+
}
167+
168+
/// Asserts that a type is `True`, aka `B1`.
169+
#[macro_export]
170+
macro_rules! assert_type {
171+
($a:ty) => {
172+
const _: core::marker::PhantomData<<$a as $crate::Same<True>>::Output> =
173+
core::marker::PhantomData;
174+
};
175+
}
176+
177+
mod sealed {
178+
use crate::{
179+
ATerm, Bit, Equal, Greater, Less, NInt, NonZero, PInt, TArr, UInt, UTerm, Unsigned, B0, B1,
180+
Z0,
181+
};
182+
183+
pub trait Sealed {}
184+
185+
impl Sealed for B0 {}
186+
impl Sealed for B1 {}
187+
188+
impl Sealed for UTerm {}
189+
impl<U: Unsigned, B: Bit> Sealed for UInt<U, B> {}
190+
191+
impl Sealed for Z0 {}
192+
impl<U: Unsigned + NonZero> Sealed for PInt<U> {}
193+
impl<U: Unsigned + NonZero> Sealed for NInt<U> {}
194+
195+
impl Sealed for Less {}
196+
impl Sealed for Equal {}
197+
impl Sealed for Greater {}
198+
199+
impl Sealed for ATerm {}
200+
impl<V, A> Sealed for TArr<V, A> {}
201+
}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
//! All of the **marker traits** used in typenum.
2+
//!
3+
//! Note that the definition here for marker traits is slightly different than
4+
//! the conventional one -- we include traits with functions that convert a type
5+
//! to the corresponding value, as well as associated constants that do the
6+
//! same.
7+
//!
8+
//! For example, the `Integer` trait includes the function (among others) `fn
9+
//! to_i32() -> i32` and the associated constant `I32` so that one can do this:
10+
//!
11+
//! ```
12+
//! use typenum::{Integer, N42};
13+
//!
14+
//! assert_eq!(-42, N42::to_i32());
15+
//! assert_eq!(-42, N42::I32);
16+
//! ```
17+
18+
use crate::sealed::Sealed;
19+
20+
/// A **marker trait** to designate that a type is not zero. All number types in this
21+
/// crate implement `NonZero` except `B0`, `U0`, and `Z0`.
22+
pub trait NonZero: Sealed {}
23+
24+
/// A **marker trait** to designate that a type is zero. Only `B0`, `U0`, and `Z0`
25+
/// implement this trait.
26+
pub trait Zero: Sealed {}
27+
28+
/// A **Marker trait** for the types `Greater`, `Equal`, and `Less`.
29+
pub trait Ord: Sealed {
30+
#[allow(missing_docs)]
31+
fn to_ordering() -> ::core::cmp::Ordering;
32+
}
33+
34+
/// The **marker trait** for compile time bits.
35+
pub trait Bit: Sealed + Copy + Default + 'static {
36+
#[allow(missing_docs)]
37+
const U8: u8;
38+
#[allow(missing_docs)]
39+
const BOOL: bool;
40+
41+
/// Instantiates a singleton representing this bit.
42+
fn new() -> Self;
43+
44+
#[allow(missing_docs)]
45+
fn to_u8() -> u8;
46+
#[allow(missing_docs)]
47+
fn to_bool() -> bool;
48+
}
49+
50+
/// The **marker trait** for compile time unsigned integers.
51+
///
52+
/// # Example
53+
/// ```rust
54+
/// use typenum::{Unsigned, U3};
55+
///
56+
/// assert_eq!(U3::to_u32(), 3);
57+
/// assert_eq!(U3::I32, 3);
58+
/// ```
59+
pub trait Unsigned: Sealed + Copy + Default + 'static {
60+
#[allow(missing_docs)]
61+
const U8: u8;
62+
#[allow(missing_docs)]
63+
const U16: u16;
64+
#[allow(missing_docs)]
65+
const U32: u32;
66+
#[allow(missing_docs)]
67+
const U64: u64;
68+
#[cfg(feature = "i128")]
69+
#[allow(missing_docs)]
70+
const U128: u128;
71+
#[allow(missing_docs)]
72+
const USIZE: usize;
73+
74+
#[allow(missing_docs)]
75+
const I8: i8;
76+
#[allow(missing_docs)]
77+
const I16: i16;
78+
#[allow(missing_docs)]
79+
const I32: i32;
80+
#[allow(missing_docs)]
81+
const I64: i64;
82+
#[cfg(feature = "i128")]
83+
#[allow(missing_docs)]
84+
const I128: i128;
85+
#[allow(missing_docs)]
86+
const ISIZE: isize;
87+
88+
#[allow(missing_docs)]
89+
fn to_u8() -> u8;
90+
#[allow(missing_docs)]
91+
fn to_u16() -> u16;
92+
#[allow(missing_docs)]
93+
fn to_u32() -> u32;
94+
#[allow(missing_docs)]
95+
fn to_u64() -> u64;
96+
#[cfg(feature = "i128")]
97+
#[allow(missing_docs)]
98+
fn to_u128() -> u128;
99+
#[allow(missing_docs)]
100+
fn to_usize() -> usize;
101+
102+
#[allow(missing_docs)]
103+
fn to_i8() -> i8;
104+
#[allow(missing_docs)]
105+
fn to_i16() -> i16;
106+
#[allow(missing_docs)]
107+
fn to_i32() -> i32;
108+
#[allow(missing_docs)]
109+
fn to_i64() -> i64;
110+
#[cfg(feature = "i128")]
111+
#[allow(missing_docs)]
112+
fn to_i128() -> i128;
113+
#[allow(missing_docs)]
114+
fn to_isize() -> isize;
115+
}
116+
117+
/// The **marker trait** for compile time signed integers.
118+
///
119+
/// # Example
120+
/// ```rust
121+
/// use typenum::{Integer, P3};
122+
///
123+
/// assert_eq!(P3::to_i32(), 3);
124+
/// assert_eq!(P3::I32, 3);
125+
/// ```
126+
pub trait Integer: Sealed + Copy + Default + 'static {
127+
#[allow(missing_docs)]
128+
const I8: i8;
129+
#[allow(missing_docs)]
130+
const I16: i16;
131+
#[allow(missing_docs)]
132+
const I32: i32;
133+
#[allow(missing_docs)]
134+
const I64: i64;
135+
#[cfg(feature = "i128")]
136+
#[allow(missing_docs)]
137+
const I128: i128;
138+
#[allow(missing_docs)]
139+
const ISIZE: isize;
140+
141+
#[allow(missing_docs)]
142+
fn to_i8() -> i8;
143+
#[allow(missing_docs)]
144+
fn to_i16() -> i16;
145+
#[allow(missing_docs)]
146+
fn to_i32() -> i32;
147+
#[allow(missing_docs)]
148+
fn to_i64() -> i64;
149+
#[cfg(feature = "i128")]
150+
#[allow(missing_docs)]
151+
fn to_i128() -> i128;
152+
#[allow(missing_docs)]
153+
fn to_isize() -> isize;
154+
}
155+
156+
/// The **marker trait** for type-level arrays of type-level numbers.
157+
///
158+
/// Someday, it may contain an associated constant to produce a runtime array,
159+
/// like the other marker traits here. However, that is blocked by [this
160+
/// issue](https://github.com/rust-lang/rust/issues/44168).
161+
pub trait TypeArray: Sealed {}
162+
163+
/// The **marker trait** for type-level numbers which are a power of two.
164+
///
165+
/// # Examples
166+
///
167+
/// Here's a working example:
168+
///
169+
/// ```rust
170+
/// use typenum::{PowerOfTwo, P4, P8};
171+
///
172+
/// fn only_p2<P: PowerOfTwo>() {}
173+
///
174+
/// only_p2::<P4>();
175+
/// only_p2::<P8>();
176+
/// ```
177+
///
178+
/// Numbers which are not a power of two will fail to compile in this example:
179+
///
180+
/// ```rust,compile_fail
181+
/// use typenum::{P9, P511, P1023, PowerOfTwo};
182+
///
183+
/// fn only_p2<P: PowerOfTwo>() { }
184+
///
185+
/// only_p2::<P9>();
186+
/// only_p2::<P511>();
187+
/// only_p2::<P1023>();
188+
/// ```
189+
pub trait PowerOfTwo: Sealed {}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
//! Aliases for the type operators used in this crate.
2+
3+
//! Their purpose is to increase the ergonomics of performing operations on the types defined
4+
//! here. For even more ergonomics, consider using the `op!` macro instead.
5+
//!
6+
//! For example, type `X` and type `Y` are the same here:
7+
//!
8+
//! ```rust
9+
//! # #[macro_use] extern crate typenum;
10+
//! use std::ops::Mul;
11+
//! use typenum::{Prod, P5, P7};
12+
//!
13+
//! type X = <P7 as Mul<P5>>::Output;
14+
//! type Y = Prod<P7, P5>;
15+
//!
16+
//! assert_type_eq!(X, Y);
17+
//! ```
18+
19+
// Aliases!!!
20+
use crate::type_operators::{
21+
Abs, Cmp, Gcd, Len, Logarithm2, Max, Min, PartialDiv, Pow, SquareRoot,
22+
};
23+
use core::ops::{Add, BitAnd, BitOr, BitXor, Div, Mul, Neg, Rem, Shl, Shr, Sub};
24+
25+
/// Alias for the associated type of `BitAnd`: `And<A, B> = <A as BitAnd<B>>::Output`
26+
pub type And<A, B> = <A as BitAnd<B>>::Output;
27+
/// Alias for the associated type of `BitOr`: `Or<A, B> = <A as BitOr<B>>::Output`
28+
pub type Or<A, B> = <A as BitOr<B>>::Output;
29+
/// Alias for the associated type of `BitXor`: `Xor<A, B> = <A as BitXor<B>>::Output`
30+
pub type Xor<A, B> = <A as BitXor<B>>::Output;
31+
32+
/// Alias for the associated type of `Shl`: `Shleft<A, B> = <A as Shl<B>>::Output`
33+
pub type Shleft<A, B> = <A as Shl<B>>::Output;
34+
/// Alias for the associated type of `Shr`: `Shright<A, B> = <A as Shr<B>>::Output`
35+
pub type Shright<A, B> = <A as Shr<B>>::Output;
36+
37+
/// Alias for the associated type of `Add`: `Sum<A, B> = <A as Add<B>>::Output`
38+
pub type Sum<A, B> = <A as Add<B>>::Output;
39+
/// Alias for the associated type of `Sub`: `Diff<A, B> = <A as Sub<B>>::Output`
40+
pub type Diff<A, B> = <A as Sub<B>>::Output;
41+
/// Alias for the associated type of `Mul`: `Prod<A, B> = <A as Mul<B>>::Output`
42+
pub type Prod<A, B> = <A as Mul<B>>::Output;
43+
/// Alias for the associated type of `Div`: `Quot<A, B> = <A as Div<B>>::Output`
44+
pub type Quot<A, B> = <A as Div<B>>::Output;
45+
/// Alias for the associated type of `Rem`: `Mod<A, B> = <A as Rem<B>>::Output`
46+
pub type Mod<A, B> = <A as Rem<B>>::Output;
47+
48+
/// Alias for the associated type of
49+
/// `PartialDiv`: `PartialQuot<A, B> = <A as PartialDiv<B>>::Output`
50+
pub type PartialQuot<A, B> = <A as PartialDiv<B>>::Output;
51+
52+
/// Alias for the associated type of `Neg`: `Negate<A> = <A as Neg>::Output`
53+
pub type Negate<A> = <A as Neg>::Output;
54+
55+
/// Alias for the associated type of `Abs`: `AbsVal<A> = <A as Abs>::Output`
56+
pub type AbsVal<A> = <A as Abs>::Output;
57+
58+
/// Alias for the associated type of `Pow`: `Exp<A, B> = <A as Pow<B>>::Output`
59+
pub type Exp<A, B> = <A as Pow<B>>::Output;
60+
61+
/// Alias for the associated type of `Gcd`: `Gcf<A, B> = <A as Gcd<B>>::Output>`
62+
pub type Gcf<A, B> = <A as Gcd<B>>::Output;
63+
64+
/// Alias to make it easy to add 1: `Add1<A> = <A as Add<B1>>::Output`
65+
pub type Add1<A> = <A as Add<crate::bit::B1>>::Output;
66+
/// Alias to make it easy to subtract 1: `Sub1<A> = <A as Sub<B1>>::Output`
67+
pub type Sub1<A> = <A as Sub<crate::bit::B1>>::Output;
68+
69+
/// Alias to make it easy to multiply by 2. `Double<A> = Shleft<A, B1>`
70+
pub type Double<A> = Shleft<A, crate::bit::B1>;
71+
72+
/// Alias to make it easy to square. `Square<A> = <A as Mul<A>>::Output`
73+
pub type Square<A> = <A as Mul>::Output;
74+
/// Alias to make it easy to cube. `Cube<A> = <Square<A> as Mul<A>>::Output`
75+
pub type Cube<A> = <Square<A> as Mul<A>>::Output;
76+
77+
/// Alias for the associated type of `SquareRoot`: `Sqrt<A> = <A as SquareRoot>::Output`
78+
pub type Sqrt<A> = <A as SquareRoot>::Output;
79+
80+
/// Alias for the associated type of `Cmp`: `Compare<A, B> = <A as Cmp<B>>::Output`
81+
pub type Compare<A, B> = <A as Cmp<B>>::Output;
82+
83+
/// Alias for the associated type of `Len`: `Length<A> = <A as Len>::Output`
84+
pub type Length<T> = <T as Len>::Output;
85+
86+
/// Alias for the associated type of `Min`: `Minimum<A, B> = <A as Min<B>>::Output`
87+
pub type Minimum<A, B> = <A as Min<B>>::Output;
88+
89+
/// Alias for the associated type of `Max`: `Maximum<A, B> = <A as Max<B>>::Output`
90+
pub type Maximum<A, B> = <A as Max<B>>::Output;
91+
92+
use crate::type_operators::{
93+
IsEqual, IsGreater, IsGreaterOrEqual, IsLess, IsLessOrEqual, IsNotEqual,
94+
};
95+
/// Alias for the associated type of `IsLess`: `Le<A, B> = <A as IsLess<B>>::Output`
96+
pub type Le<A, B> = <A as IsLess<B>>::Output;
97+
/// Alias for the associated type of `IsEqual`: `Eq<A, B> = <A as IsEqual<B>>::Output`
98+
pub type Eq<A, B> = <A as IsEqual<B>>::Output;
99+
/// Alias for the associated type of `IsGreater`: `Gr<A, B> = <A as IsGreater<B>>::Output`
100+
pub type Gr<A, B> = <A as IsGreater<B>>::Output;
101+
/// Alias for the associated type of `IsGreaterOrEqual`:
102+
/// `GrEq<A, B> = <A as IsGreaterOrEqual<B>>::Output`
103+
pub type GrEq<A, B> = <A as IsGreaterOrEqual<B>>::Output;
104+
/// Alias for the associated type of `IsLessOrEqual`: `LeEq<A, B> = <A as IsLessOrEqual<B>>::Output`
105+
pub type LeEq<A, B> = <A as IsLessOrEqual<B>>::Output;
106+
/// Alias for the associated type of `IsNotEqual`: `NotEq<A, B> = <A as IsNotEqual<B>>::Output`
107+
pub type NotEq<A, B> = <A as IsNotEqual<B>>::Output;
108+
/// Alias for the associated type of `Logarithm2`: `Log2<A> = <A as Logarithm2>::Output`
109+
pub type Log2<A> = <A as Logarithm2>::Output;

‎collector/compile-benchmarks/typenum-1.17.0/src/private.rs

Lines changed: 587 additions & 0 deletions
Large diffs are not rendered by default.

‎collector/compile-benchmarks/typenum-1.17.0/src/type_operators.rs

Lines changed: 600 additions & 0 deletions
Large diffs are not rendered by default.

‎collector/compile-benchmarks/typenum-1.17.0/src/uint.rs

Lines changed: 2663 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[cfg(test)]
2+
include!(concat!(env!("OUT_DIR"), "/tests.rs"));

0 commit comments

Comments
 (0)
Please sign in to comment.