Skip to content

Commit 12c1d1c

Browse files
authored
Merge pull request #18 from rust-amplify/develop
Update dependencies, fix u1::to_u8, version bump
2 parents 1a89c7a + ce9f57c commit 12c1d1c

File tree

9 files changed

+414
-128
lines changed

9 files changed

+414
-128
lines changed

Cargo.lock

+16-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apfloat/Cargo.toml

+3-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ authors = [
44
"Yudai Kiyofuji <[email protected]>"
55
]
66
name = "amplify_apfloat"
7-
version = "0.2.0"
7+
version = "0.3.0"
88
description = "rustc_apfloat with u256 backend to utilize Octuple precision floating-point format"
99
license = "MIT OR Apache-2.0"
1010
repository = "https://github.com/rust-amplify/rust-amplify"
@@ -21,8 +21,8 @@ alloc = ["amplify_num/alloc"]
2121
std = ["amplify_num/std"]
2222

2323
[dependencies]
24-
amplify_num = { version = "0.5.0", path = "../num", default-features = false }
25-
bitflags = "1.0"
24+
amplify_num = { version = "0.6.0", path = "../num", default-features = false }
25+
bitflags = "2.4.1"
2626

2727
[target.'cfg(target_arch = "wasm32")'.dependencies]
2828
wasm-bindgen = "0.2"
@@ -31,8 +31,3 @@ getrandom = { version = "0.2", features = ["js"], optional = true }
3131

3232
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
3333
wasm-bindgen-test = "0.3"
34-
35-
[target.'cfg(target_arch = "wasm32")'.features]
36-
default = ["std"]
37-
alloc = ["amplify_num/alloc"]
38-
std = ["amplify_num/std"]

apfloat/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ mod status {
8585
///
8686
/// UNDERFLOW or OVERFLOW are always returned or-ed with INEXACT.
8787
#[must_use]
88+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
8889
pub struct Status: u8 {
8990
const OK = 0x00;
9091
const INVALID_OP = 0x01;
@@ -98,7 +99,7 @@ mod status {
9899
pub use status::Status;
99100

100101
#[must_use]
101-
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
102+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
102103
pub struct StatusAnd<T> {
103104
pub status: Status,
104105
pub value: T,

num/Cargo.toml

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "amplify_num"
3-
version = "0.5.1"
3+
version = "0.6.0"
44
description = "Amplifying numeric types: big-sized and bit-sized integers"
55
authors = [
66
"Dr. Maxim Orlovsky <[email protected]>",
@@ -21,8 +21,7 @@ rust-version = "1.60.0"
2121
serde_crate = { package = "serde", version = "1.0", features = ["derive"], optional = true }
2222

2323
[dev-dependencies]
24-
bincode = "1.3.3"
25-
rand = "0.8.4"
24+
rand = "0.8.5"
2625
serde_crate = { package = "serde", version = "1.0", features = ["derive"] }
2726
serde_json = "1"
2827

@@ -41,11 +40,3 @@ getrandom = { version = "0.2", features = ["js"], optional = true }
4140

4241
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
4342
wasm-bindgen-test = "0.3"
44-
45-
[target.'cfg(target_arch = "wasm32")'.features]
46-
default = ["hex"]
47-
all = ["std", "hex", "serde"]
48-
std = []
49-
serde = ["std", "serde_crate", "hex"]
50-
hex = []
51-
alloc = []

num/src/bigint.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//
44
// Written in 2014 by
55
// Andrew Poelstra <[email protected]>
6-
// Refactored & fixed in 2021 by
7-
// Dr. Maxim Orlovsky <orlovsky@pandoracore.com>
6+
// Refactored & fixed in 2021-2024 by
7+
// Dr. Maxim Orlovsky <orlovsky@ubideco.org>
88
//
99
// To the extent possible under law, the author(s) have dedicated all
1010
// copyright and related and neighboring rights to this software to
@@ -1526,7 +1526,7 @@ mod tests {
15261526
#[test]
15271527
fn fmt_hex() {
15281528
let one = u256::ONE;
1529-
let mut u_256 =
1529+
let u_256 =
15301530
u256([0x0000000000000000, 0xAAAAAAAABBBBBBBB, 0x0000000111122222, 0x0000000000000000]);
15311531

15321532
// UpperHex
@@ -1554,7 +1554,7 @@ mod tests {
15541554
#[test]
15551555
fn fmt_octal() {
15561556
let one = u256::ONE;
1557-
let mut u_256 = u256([
1557+
let u_256 = u256([
15581558
0o0000000000000000000000,
15591559
0o0011222222222222222222,
15601560
0o0000000001111111111111,
@@ -1581,7 +1581,7 @@ mod tests {
15811581
#[test]
15821582
fn fmt_binary() {
15831583
let one = u256::ONE;
1584-
let mut u_256 = u256([
1584+
let u_256 = u256([
15851585
0b0000000000000000000000000000000000000000000000000000000000000000,
15861586
0b0001111000011110001111000011110001111000011110001111000011110000,
15871587
0b0000000000000000000000000000001111111111111111111111111111111111,
@@ -1867,10 +1867,6 @@ mod tests {
18671867
let json = format!("\"{}\"", hex);
18681868
assert_eq!(::serde_json::to_string(&uint).unwrap(), json);
18691869
assert_eq!(::serde_json::from_str::<u256>(&json).unwrap(), uint);
1870-
1871-
let bin_encoded = ::bincode::serialize(&uint).unwrap();
1872-
let bin_decoded: u256 = ::bincode::deserialize(&bin_encoded).unwrap();
1873-
assert_eq!(bin_decoded, uint);
18741870
};
18751871

18761872
check(u256::from(0u64), "0000000000000000000000000000000000000000000000000000000000000000");

num/src/error.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
//
44
// Written in 2014 by
55
// Andrew Poelstra <[email protected]>
6-
// Updated in 2020-2021 by
7-
// Dr. Maxim Orlovsky <orlovsky@pandoracore.com>
6+
// Updated in 2020-2024 by
7+
// Dr. Maxim Orlovsky <orlovsky@ubideco.org>
88
//
99
// To the extent possible under law, the author(s) have dedicated all
1010
// copyright and related and neighboring rights to this software to
@@ -17,11 +17,11 @@
1717

1818
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
1919
/// Error indicating that a value does not fit integer dimension
20-
pub struct OverflowError {
20+
pub struct OverflowError<T = usize> {
2121
/// Integer bit size
22-
pub max: usize,
22+
pub max: T,
2323
/// Value that overflows
24-
pub value: usize,
24+
pub value: T,
2525
}
2626

2727
impl core::fmt::Display for OverflowError {

num/src/lib.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// Rust language amplification library providing multiple generic trait
22
// implementations, type wrappers, derive macros and other language enhancements
33
//
4-
// Written in 2014 by
5-
// Andrew Poelstra <[email protected]>
6-
// Updated in 2020-2021 by
7-
// Dr. Maxim Orlovsky <[email protected]>
4+
// Written in 2020-2024 by
5+
// Dr. Maxim Orlovsky <[email protected]>
86
//
97
// To the extent possible under law, the author(s) have dedicated all
108
// copyright and related and neighboring rights to this software to
@@ -17,12 +15,13 @@
1715

1816
//! Custom-sized numeric types
1917
//!
20-
//! Implementation of a various integer types with custom bit dimension. These
18+
//! Implementation of a various integer types with custom bit dimension. This
2119
//! includes:
22-
//! * large signed and unsigned integers, named *gib int types* (256, 512,
20+
//! * large signed and unsigned integers, named *large int types* (256, 512,
2321
//! 1024-bit)
24-
//! * custom sub-8 bit unsigned integers, named *small int types (5-, 6-, 7-bit)
25-
//! * 24-bit signed integer.
22+
//! * custom sub-8 bit unsigned integers, named *small int types* (from 1 to
23+
//! 7-bit)
24+
//! * 24-, 40-, 48- and 56-bit unsigned integer.
2625
//!
2726
//! The functions here are designed to be fast.
2827
@@ -43,7 +42,7 @@ pub mod posit;
4342
mod smallint;
4443

4544
pub use bigint::{i1024, i256, i512, u1024, u256, u512};
46-
pub use smallint::{u1, u2, u24, u3, u4, u5, u6, u7};
45+
pub use smallint::{u1, u2, u24, u3, u4, u40, u48, u5, u56, u6, u7};
4746

4847
// TODO: Create arbitrary precision types
4948
// TODO: Move from using `u64` to `u128` for big int types

0 commit comments

Comments
 (0)