kennytm / extprim Goto Github PK
View Code? Open in Web Editor NEWExtra primitive types (u128, i128) for Rust.
License: Apache License 2.0
Extra primitive types (u128, i128) for Rust.
License: Apache License 2.0
The MIT license requires reproducing countless copies of the same copyright
header with different names in the copyright field, for every MIT library in
use. The Apache license does not have this drawback, and has protections from
patent trolls and an explicit contribution licensing clause. However, the
Apache license is incompatible with GPLv2. This is why Rust is dual-licensed as
MIT/Apache (the "primary" license being Apache, MIT only for GPLv2 compat), and
doing so would be wise for this project. This also makes this crate suitable
for inclusion in the Rust standard distribution and other project using dual
MIT/Apache.
To do this, get explicit approval from each contributor of copyrightable work
(as not all contributions qualify for copyright) and then add the following to
your README:
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you shall be dual licensed as above, without any
additional terms or conditions.
and in your license headers, use the following boilerplate (based on that used in Rust):
// Copyright (c) 2015 t developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be copied, modified, or distributed except
// according to those terms.
And don't forget to update the license
metadata in your Cargo.toml
!
The failures have broken libc's CI: https://cirrus-ci.com/task/6019469988593664?command=test#L802
Running `LD_LIBRARY_PATH='/tmp/cirrus-ci-build/target/debug/deps:/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib:/.rustup/toolchains/nightly-x86_64-unknown-freebsd/lib' CARGO=/.rustup/toolchains/nightly-x86_64-unknown-freebsd/bin/cargo CARGO_PKG_VERSION_PRE= OUT_DIR=/tmp/cirrus-ci-build/target/debug/build/extprim-5e5a52523eb5ec17/out CARGO_PKG_DESCRIPTION='Extra primitive types (u128, i128)' CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_NAME=extprim CARGO_PKG_AUTHORS='kennytm <[email protected]>' CARGO_PKG_HOMEPAGE= CARGO_PKG_VERSION_MINOR=7 CARGO_MANIFEST_DIR=/.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION=1.7.0 CARGO_PKG_REPOSITORY='https://github.com/kennytm/extprim' rustc --crate-name extprim /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/lib.rs --color never --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="rand"' --cfg 'feature="serde"' --cfg 'feature="use-std"' -C metadata=c4fcad300f905e65 -C extra-filename=-c4fcad300f905e65 --out-dir /tmp/cirrus-ci-build/target/debug/deps -L dependency=/tmp/cirrus-ci-build/target/debug/deps --extern num_traits=/tmp/cirrus-ci-build/target/debug/deps/libnum_traits-d7ad901a1da51360.rlib --extern rand=/tmp/cirrus-ci-build/target/debug/deps/librand-d89ed4fe529ebdac.rlib --extern serde=/tmp/cirrus-ci-build/target/debug/deps/libserde-7727c95b4cb5c292.rlib --cap-lints warn --cfg 'extprim_channel="unstable"' --cfg extprim_has_stable_i128`
error: `X...` range patterns are not supported
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:94:21
|
94 | 1 ... $e => u128::new(mantissa) << exp,
| ^^^^^ help: try using the maximum value for the type: `1...MAX`
...
117 | impl_to_extra_primitive_for_float!(f32, 23, 104, 103);
| ------------------------------------------------------ in this macro invocation
error: expected one of `=>`, `if`, or `|`, found `104`
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:94:27
|
94 | 1 ... $e => u128::new(mantissa) << exp,
| ^^ expected one of `=>`, `if`, or `|` here
...
117 | impl_to_extra_primitive_for_float!(f32, 23, 104, 103);
| ------------------------------------------------------ in this macro invocation
error: `X...` range patterns are not supported
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:103:21
|
103 | 1 ... $f => u128::new(mantissa) << exp,
| ^^^^^ help: try using the maximum value for the type: `1...MAX`
...
117 | impl_to_extra_primitive_for_float!(f32, 23, 104, 103);
| ------------------------------------------------------ in this macro invocation
error: expected one of `=>`, `if`, or `|`, found `103`
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:103:27
|
103 | 1 ... $f => u128::new(mantissa) << exp,
| ^^ expected one of `=>`, `if`, or `|` here
...
117 | impl_to_extra_primitive_for_float!(f32, 23, 104, 103);
| ------------------------------------------------------ in this macro invocation
error: `X...` range patterns are not supported
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:94:21
|
94 | 1 ... $e => u128::new(mantissa) << exp,
| ^^^^^ help: try using the maximum value for the type: `1...MAX`
...
118 | impl_to_extra_primitive_for_float!(f64, 52, 75, 74);
| ---------------------------------------------------- in this macro invocation
error: expected one of `=>`, `if`, or `|`, found `75`
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:94:27
|
94 | 1 ... $e => u128::new(mantissa) << exp,
| ^^ expected one of `=>`, `if`, or `|` here
...
118 | impl_to_extra_primitive_for_float!(f64, 52, 75, 74);
| ---------------------------------------------------- in this macro invocation
error: `X...` range patterns are not supported
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:103:21
|
103 | 1 ... $f => u128::new(mantissa) << exp,
| ^^^^^ help: try using the maximum value for the type: `1...MAX`
...
118 | impl_to_extra_primitive_for_float!(f64, 52, 75, 74);
| ---------------------------------------------------- in this macro invocation
error: expected one of `=>`, `if`, or `|`, found `74`
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:103:27
|
103 | 1 ... $f => u128::new(mantissa) << exp,
| ^^ expected one of `=>`, `if`, or `|` here
...
118 | impl_to_extra_primitive_for_float!(f64, 52, 75, 74);
| ---------------------------------------------------- in this macro invocation
warning: `...` range patterns are deprecated
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:93:25
|
93 | -$d ... 0 => u128::new(mantissa >> -exp),
| ^^^ help: use `..=` for an inclusive range
...
117 | impl_to_extra_primitive_for_float!(f32, 23, 104, 103);
| ------------------------------------------------------ in this macro invocation
|
= note: `#[warn(ellipsis_inclusive_range_patterns)]` on by default
warning: `...` range patterns are deprecated
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:102:25
|
102 | -$d ... 0 => u128::new(mantissa >> -exp),
| ^^^ help: use `..=` for an inclusive range
...
117 | impl_to_extra_primitive_for_float!(f32, 23, 104, 103);
| ------------------------------------------------------ in this macro invocation
warning: `...` range patterns are deprecated
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:93:25
|
93 | -$d ... 0 => u128::new(mantissa >> -exp),
| ^^^ help: use `..=` for an inclusive range
...
118 | impl_to_extra_primitive_for_float!(f64, 52, 75, 74);
| ---------------------------------------------------- in this macro invocation
warning: `...` range patterns are deprecated
--> /.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.0/src/traits.rs:102:25
|
102 | -$d ... 0 => u128::new(mantissa >> -exp),
| ^^^ help: use `..=` for an inclusive range
...
118 | impl_to_extra_primitive_for_float!(f64, 52, 75, 74);
| ---------------------------------------------------- in this macro invocation
error: aborting due to 8 previous errors
error: Could not compile `extprim`.
Doc-tests extprim_literals
Running `rustdoc --test /builddir/build/BUILD/extprim_literals-2.0.0/src/lib.rs --crate-name extprim_literals -L dependency=/builddir/build/BUILD/extprim_literals-2.0.0/target/release/deps --extern extprim_literals_macros=/builddir/build/BUILD/extprim_literals-2.0.0/target/release/deps/libextprim_literals_macros-03fbbc262cde0055.so --extern extprim_literals=/builddir/build/BUILD/extprim_literals-2.0.0/target/release/deps/libextprim_literals-b6aef87701955993.rlib --extern procedural_masquerade=/builddir/build/BUILD/extprim_literals-2.0.0/target/release/deps/libprocedural_masquerade-27c6b7fc26f91603.rlib`
running 3 tests
test src/lib.rs - (line 19) ... ignored
test src/lib.rs - i128 (line 58) ... FAILED
test src/lib.rs - u128 (line 36) ... FAILED
failures:
---- src/lib.rs - i128 (line 58) stdout ----
error: cannot find macro `i128!` in this scope
--> <anon>:7:1
|
7 | i128!(-0b11000111001101001100001010010111110101000101011011011111101111111111110101110110);
| ^^^^
error: cannot find macro `i128!` in this scope
--> <anon>:6:1
|
6 | i128!(0o1_151760_574675_745253_103376_166404_235110_762614);
| ^^^^
error: cannot find macro `i128!` in this scope
--> <anon>:5:1
|
5 | i128!(-0x34c1b7a2_2955e5bb_03cc1a88_342b9e8d);
| ^^^^
error: cannot find macro `i128!` in this scope
--> <anon>:4:1
|
4 | i128!(-42128403654828209595896121373164578595);
| ^^^^
error: cannot find macro `i128!` in this scope
--> <anon>:3:1
|
3 | i128!(+1241909465635371210237387091769850650);
| ^^^^
error: cannot find macro `i128!` in this scope
--> <anon>:2:1
|
2 | i128!(123623219786789911069641050508607316353);
| ^^^^
error: aborting due to 6 previous errors
error: aborting due to 6 previous errors
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:456
note: Run with `RUST_BACKTRACE=1` for a backtrace.
thread 'rustc' panicked at 'couldn't compile the test', src/librustdoc/test.rs:273
error[E0557]: feature has been removed
Error: --> /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.7.1/src/lib.rs:58:81
|
58 | #![cfg_attr(extprim_channel="unstable", feature(llvm_asm, test, specialization, const_fn))]
| ^^^^^^^^ feature has been removed
|
= note: split into finer-grained feature gates
rustc 1.54.0-nightly (21e92b973 2021-05-12)
Would it be possible to release an extprim 1.7.1 soon so that we can get #18 out there? Currently ctest is broken downstream on nightly because of this.
Just a FYI.
It would be nice if this library was updated.
Thanks!
Seems like my rustc
is too new (the new builtin type is stable now).
It's unable to distinguish whether the fn
for the builtin or for the type in this crate should be used.
Exact error message:
error[E0034]: multiple applicable items in scope
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\u128.rs:1533:11
|
1533 | n.to_u128()
| ^^^^^^^ multiple `to_u128` found
|
note: candidate #1 is defined in an impl of the trait `traits::ToExtraPrimitive` for the type `u64`
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\traits.rs:40:5
|
40 | fn to_u128(&self) -> Option<u128> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: candidate #2 is defined in an impl of the trait `num_traits::ToPrimitive` for the type `u64`
error[E0034]: multiple applicable items in scope
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\u128.rs:1537:11
|
1537 | n.to_u128()
| ^^^^^^^ multiple `to_u128` found
|
note: candidate #1 is defined in an impl of the trait `traits::ToExtraPrimitive` for the type `i64`
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\traits.rs:50:5
|
50 | fn to_u128(&self) -> Option<u128> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: candidate #2 is defined in an impl of the trait `num_traits::ToPrimitive` for the type `i64`
error[E0034]: multiple applicable items in scope
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\u128.rs:1541:11
|
1541 | n.to_u128()
| ^^^^^^^ multiple `to_u128` found
|
note: candidate #1 is defined in an impl of the trait `traits::ToExtraPrimitive` for the type `f64`
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\traits.rs:69:13
|
69 | fn to_u128(&self) -> Option<u128> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
98 | impl_to_extra_primitive_for_float!(f64, 52, 75, 74);
| ---------------------------------------------------- in this macro invocation
= note: candidate #2 is defined in an impl of the trait `num_traits::ToPrimitive` for the type `f64`
error[E0034]: multiple applicable items in scope
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\i128.rs:1288:11
|
1288 | n.to_i128()
| ^^^^^^^ multiple `to_i128` found
|
note: candidate #1 is defined in an impl of the trait `traits::ToExtraPrimitive` for the type `u64`
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\traits.rs:44:5
|
44 | fn to_i128(&self) -> Option<i128> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: candidate #2 is defined in an impl of the trait `num_traits::ToPrimitive` for the type `u64`
error[E0034]: multiple applicable items in scope
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\i128.rs:1292:11
|
1292 | n.to_i128()
| ^^^^^^^ multiple `to_i128` found
|
note: candidate #1 is defined in an impl of the trait `traits::ToExtraPrimitive` for the type `i64`
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\traits.rs:58:5
|
58 | fn to_i128(&self) -> Option<i128> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: candidate #2 is defined in an impl of the trait `num_traits::ToPrimitive` for the type `i64`
error[E0034]: multiple applicable items in scope
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\i128.rs:1296:11
|
1296 | n.to_i128()
| ^^^^^^^ multiple `to_i128` found
|
note: candidate #1 is defined in an impl of the trait `traits::ToExtraPrimitive` for the type `f64`
--> C:\Users\admin\.cargo\registry\src\github.com-1ecc6299db9ec823\extprim-1.5.1\src\traits.rs:79:13
|
79 | fn to_i128(&self) -> Option<i128> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
98 | impl_to_extra_primitive_for_float!(f64, 52, 75, 74);
| ---------------------------------------------------- in this macro invocation
= note: candidate #2 is defined in an impl of the trait `num_traits::ToPrimitive` for the type `f64`
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0034`.
Not sure what to do here.
╰─$ cargo build --release
Compiling extprim v1.6.0
Compiling bio v0.18.0
error[E0407]: method `to_i128` is not a member of trait `ToPrimitive`
--> /mnt/home/avi.srivastava/.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.6.0/src/u128.rs:1542:5
|
1542 | / fn to_i128(&self) -> Option<I128> {
1543 | | if self.hi < 0x80000000_00000000 {
1544 | | Some(self.as_built_in() as I128)
1545 | | } else {
1546 | | None
1547 | | }
1548 | | }
| |_____^ not a member of trait `ToPrimitive`
Compiling the crate on the current nightly rustc 1.17.0-nightly (ea7a6486a 2017-02-04)
fails:
# cargo test -v
Compiling extprim v1.2.0 (file:///tmp/extprim)
Running `rustc --crate-name extprim src/lib.rs --emit=dep-info,link -C debuginfo=2 --test --cfg 'feature="use-std"' --cfg 'feature="rand"' --cfg 'feature="default"' -C metadata=b758bf3847a72ee2 -C extra-filename=-b758bf3847a72ee2 --out-dir /tmp/extprim/target/debug/deps -L dependency=/tmp/extprim/target/debug/deps --extern num_traits=/tmp/extprim/target/debug/deps/libnum_traits-51f88ce8f32c0283.rlib --extern rand=/tmp/extprim/target/debug/deps/librand-c9d9fbdab2355ee4.rlib --cfg 'extprim_channel="unstable"'`
Running `rustc --crate-name extprim src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg 'feature="use-std"' --cfg 'feature="rand"' --cfg 'feature="default"' -C metadata=62ecc1eba452488f -C extra-filename=-62ecc1eba452488f --out-dir /tmp/extprim/target/debug/deps -L dependency=/tmp/extprim/target/debug/deps --extern num_traits=/tmp/extprim/target/debug/deps/libnum_traits-51f88ce8f32c0283.rlib --extern rand=/tmp/extprim/target/debug/deps/librand-c9d9fbdab2355ee4.rlib --cfg 'extprim_channel="unstable"'`
error[E0463]: can't find crate for `rustc_i128`
--> src/lib.rs:66:36
|
66 | #[cfg(extprim_channel="unstable")] extern crate rustc_i128;
| ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
error[E0463]: can't find crate for `rustc_i128`
--> src/lib.rs:66:36
|
66 | #[cfg(extprim_channel="unstable")] extern crate rustc_i128;
| ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to previous error
error: aborting due to previous error
error: Could not compile `extprim`.
Caused by:
process didn't exit successfully: `rustc --crate-name extprim src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 --cfg feature="use-std" --cfg feature="rand" --cfg feature="default" -C metadata=62ecc1eba452488f -C extra-filename=-62ecc1eba452488f --out-dir /tmp/extprim/target/debug/deps -L dependency=/tmp/extprim/target/debug/deps --extern num_traits=/tmp/extprim/target/debug/deps/libnum_traits-51f88ce8f32c0283.rlib --extern rand=/tmp/extprim/target/debug/deps/librand-c9d9fbdab2355ee4.rlib --cfg extprim_channel="unstable"` (exit code: 101)
Build failed, waiting for other jobs to finish...
error: build failed
This line comes from d152991
Apache-2.0 requires text license to be presented along with sources.. From upstream git POV it is there, but uploaded crate on crates.io doesn't have it.
See https://github.com/brson/rust-api-guidelines#c-serde. It seems like stabilization of u128 is still a ways off (rust-lang/rust#35118). Would there be interest in a PR to add serde support as a cfg feature? I'm willing to take a crack at it.
I think this is a forgotten debug output and it is not possible to compile extprim 1.5 with default-features = false
(without std):
error: cannot find macro `println!` in this scope
--> /home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/extprim-1.5.0/src/u128.rs:2387:13
|
2387 | println!(">>> {}, {} <<<", acc, elem);
| ^^^^^^^
Line 2387 in b2cc980
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.