Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more const constructors and various convenience functions to Number for generic conversions #47

Merged
merged 10 commits into from
Dec 13, 2024
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Changelog

## arbitrary-int 1.2.8
## arbitrary-int 1.3.0

### Added

- New optional feature `hint`, which tells the compiler that the returned `value()` can't exceed a maximum value. This
allows the compiler to optimize faster code at the expense of unsafe code within arbitrary-int itself.
- Various new const constructors: `new_u8`, `new_u16`, ..., `new_u128` which allow creating an arbitrary int without
type conversion, e.g. `u5::new_u32(i)` (where i is e.g. u32). This is shorter than writing
`u5::new(i.try_into().unwrap())`,
and combines two possible panic paths into one. Also, unlike `try_into().unwrap()`, the new constructors are usable in
const contexts.
- For non-const contexts, `new_()` allows any Number argument to be passed through generics.
- `as_()` easily converts any Number to another. `as_u8()`, `as_u16()` for more control (and to implement the others).
- New optional feature `borsh` to support binary serialization using the borsh crate.

## arbitrary-int 1.2.7

Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "arbitrary-int"
version = "1.2.7"
version = "1.3.0"
edition = "2021"
authors = ["Daniel Lehmann <[email protected]>"]
description = "Modern and lightweight implementation of u2, u3, u4, ..., u127."
Expand All @@ -15,7 +15,9 @@ std = []

# Supports const trait implementation through const_convert and const_trait_impl. Support for those was removed
# from more recent Rust nightlies, so this feature requires an older Rust compiler
# (2023-04-20 is broken, 2022-11-23 works. The exact day is somewhere inbetween)
# (2023-04-20 is broken, 2022-11-23 works. The exact day is somewhere inbetween).
# As of 12/2/2024, this also uses inline_const. This has been stabilized but is required for current code to work
# on the old compiler.
const_convert_and_const_trait_impl = []
Comment on lines 16 to 21

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danlehmann With 1.3.0 being incompatible to previous versions anyway and inline_const having been stabilized in Rust 1.79.0, may it be a good time to raise the MSRV to 1.79 and just remove this optional feature?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is still used by https://crates.io/crates/bilge (which itself puts it behind an optional feature). While I really dislike the code duplication, I don't want to break them. I think the right time to remove the feature is when const_convert/const_trait become finalized.

In terms of breakage, I think 1.3.0 doesn't break much. I'd like to keep it at a minimum.


# core::fmt::Step is currently unstable and is available on nightly behind a feature gate
Expand Down
Loading
Loading