Skip to content

Commit 8023524

Browse files
authored
Merge pull request #21 from cuviper/release-0.3.5
Release 0.3.5
2 parents 970f066 + 4d90855 commit 8023524

6 files changed

Lines changed: 43 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
rust: [
15-
1.91.0, # MSRV
15+
1.93.0, # MSRV
1616
stable,
1717
beta,
1818
nightly,
@@ -52,7 +52,7 @@ jobs:
5252
runs-on: ubuntu-latest
5353
steps:
5454
- uses: actions/checkout@v4
55-
- uses: dtolnay/rust-toolchain@1.91.0
55+
- uses: dtolnay/rust-toolchain@1.93.0
5656
with:
5757
components: rustfmt
5858
- run: cargo fmt --all --check

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "num-primitive"
3-
version = "0.3.4"
3+
version = "0.3.5"
44
description = "Traits for primitive numeric types"
55
repository = "https://github.com/rust-num/num-primitive"
66
license = "MIT OR Apache-2.0"
77
keywords = ["generic", "mathematics", "numerics", "primitive"]
88
categories = ["algorithms", "science", "no-std"]
99
edition = "2024"
10-
rust-version = "1.91"
10+
rust-version = "1.93"
1111

1212
[package.metadata.release]
1313
allow-branch = ["main"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![crate](https://img.shields.io/crates/v/num-primitive.svg)](https://crates.io/crates/num-primitive)
44
[![documentation](https://docs.rs/num-primitive/badge.svg)](https://docs.rs/num-primitive)
5-
[![minimum rustc 1.91](https://img.shields.io/badge/rustc-1.91+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
5+
[![minimum rustc 1.93](https://img.shields.io/badge/rustc-1.93+-red.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
66
[![build status](https://github.com/rust-num/num-primitive/workflows/CI/badge.svg)](https://github.com/rust-num/num-primitive/actions)
77

88
Traits for primitive numeric types in Rust.
@@ -61,7 +61,7 @@ Release notes are available in [RELEASES.md](RELEASES.md).
6161

6262
## Compatibility
6363

64-
The `num-primitive` crate is currently tested for Rust 1.91 and greater. This
64+
The `num-primitive` crate is currently tested for Rust 1.93 and greater. This
6565
minimum-supported Rust version (MSRV) may be increased at any time to add
6666
support for newly-stabilized functionality from the standard library. Changes
6767
will be documented prominently in the release notes.

RELEASES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Release 0.3.5 (2026-01-22)
2+
3+
- Updated to MSRV 1.93.
4+
- Added `PrimitiveInteger::unchecked_{shl,shr}`.
5+
- Added `PrimitiveSigned::unchecked_neg`.
6+
17
# Release 0.3.4 (2025-12-20)
28

39
- Added `PrimitiveInteger::from_str_radix`.

src/integer.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,24 @@ pub trait PrimitiveInteger:
492492
/// Self::MIN`, i.e. when [`checked_mul`][Self::checked_mul] would return `None`.
493493
unsafe fn unchecked_mul(self, rhs: Self) -> Self;
494494

495+
/// Unchecked shift left. Computes `self << rhs`, assuming that
496+
/// `rhs` is less than the number of bits in `self`.
497+
///
498+
/// # Safety
499+
///
500+
/// This results in undefined behavior if `rhs` is larger than or equal to the number of bits
501+
/// in `self`, i.e. when [`checked_shl`][Self::checked_shl] would return `None`.
502+
unsafe fn unchecked_shl(self, rhs: u32) -> Self;
503+
504+
/// Unchecked shift right. Computes `self >> rhs`, assuming that
505+
/// `rhs` is less than the number of bits in `self`.
506+
///
507+
/// # Safety
508+
///
509+
/// This results in undefined behavior if `rhs` is larger than or equal to the number of bits
510+
/// in `self`, i.e. when [`checked_shr`][Self::checked_shr] would return `None`.
511+
unsafe fn unchecked_shr(self, rhs: u32) -> Self;
512+
495513
/// Unchecked integer subtraction. Computes `self - rhs`, assuming overflow cannot occur.
496514
///
497515
/// # Safety
@@ -668,6 +686,8 @@ macro_rules! impl_integer {
668686
forward! {
669687
unsafe fn unchecked_add(self, rhs: Self) -> Self;
670688
unsafe fn unchecked_mul(self, rhs: Self) -> Self;
689+
unsafe fn unchecked_shl(self, rhs: u32) -> Self;
690+
unsafe fn unchecked_shr(self, rhs: u32) -> Self;
671691
unsafe fn unchecked_sub(self, rhs: Self) -> Self;
672692
}
673693
}

src/signed.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ pub trait PrimitiveSigned:
146146
/// Wrapping (modular) subtraction with an unsigned integer. Computes `self - rhs`, wrapping
147147
/// around at the boundary of the type.
148148
fn wrapping_sub_unsigned(self, rhs: Self::Unsigned) -> Self;
149+
150+
/// Unchecked negation. Computes `-self`, assuming overflow cannot occur.
151+
///
152+
/// # Safety
153+
///
154+
/// This results in undefined behavior when `self == Self::MIN`, i.e. when
155+
/// [`checked_neg`][PrimitiveInteger::checked_neg] would return `None`.
156+
unsafe fn unchecked_neg(self) -> Self;
149157
}
150158

151159
/// Trait for references to primitive signed integer types ([`PrimitiveSigned`]).
@@ -185,6 +193,9 @@ macro_rules! impl_signed {
185193
fn wrapping_add_unsigned(self, rhs: Self::Unsigned) -> Self;
186194
fn wrapping_sub_unsigned(self, rhs: Self::Unsigned) -> Self;
187195
}
196+
forward! {
197+
unsafe fn unchecked_neg(self) -> Self;
198+
}
188199
}
189200

190201
impl PrimitiveSignedRef<$Signed> for &$Signed {}

0 commit comments

Comments
 (0)