Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust 1.46
name: Rust 1.57

on:
push:
Expand All @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@1.46
- uses: dtolnay/rust-toolchain@1.57
- name: Run tests (no default features)
run: cargo test --no-default-features
- name: Run tests (default features)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readme = "README.md"
repository = "https://github.com/ruma/js_int"
keywords = ["integer", "no_std"]
categories = ["no-std"]
rust-version = "1.46.0"
rust-version = "1.57.0"

[dependencies.serde]
version = "1.0"
Expand Down
33 changes: 2 additions & 31 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,7 @@ macro_rules! int {
($n:expr) => {{
const VALUE: $crate::Int = match $crate::Int::new($n) {
Some(int) => int,
None => {
// Hack to emulate a panic in this case.
// Inspired by the [`static_assertions`](https://github.com/nvzqz/static-assertions) package.
// Improvements to be made with higher MSRVs:
// * 1.48: Replace the number comparison with `Option::is_none`
// * 1.57: Use `panic!()` directly.
// * 1.83: Replace manual `panic!()` with `Option::expect`
const _: [(); 0 - !{
const ASSERT: bool = $n >= $crate::MIN_SAFE_INT && $n <= $crate::MAX_SAFE_INT;
ASSERT
} as usize] = [];
// This loop should not run, but it produces a never type that keeps the match
// arms having the same type (since never conforms to any type)
loop {}
}
None => panic!("Number is outside the range of an Int"),
};
VALUE
}};
Expand All @@ -32,22 +18,7 @@ macro_rules! uint {
($n:expr) => {{
const VALUE: $crate::UInt = match $crate::UInt::new($n) {
Some(int) => int,
None => {
// Hack to emulate a panic in this case.
// Inspired by the [`static_assertions`](https://github.com/nvzqz/static-assertions) package.
// Improvements to be made with higher MSRVs:
// * 1.48: Replace the number comparison with `Option::is_none`
// * 1.57: Use `panic!()` directly.
// * 1.83: Replace manual `panic!()` with `Option::expect`
#[allow(unknown_lints, unused_comparisons)]
const _: [(); 0 - !{
const ASSERT: bool = $n <= $crate::MAX_SAFE_UINT;
ASSERT
} as usize] = [];
// This loop should not run, but it produces a never type that keeps the match
// arms having the same type (since never conforms to any type)
loop {}
}
None => panic!("Number is outside the range of an Int"),
};
VALUE
}};
Expand Down