Skip to content

Commit

Permalink
release: 0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Jan 9, 2025
2 parents a258305 + d1b7fc9 commit 0e37dba
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@



## [0.9.1](https://github.com/Blobfolio/dactyl/releases/tag/v0.9.1) - 2025-01-09

### Changed

* Bump `brunch` to `0.8`
* Round non-normal `NicePercent` arguments to nearest of `MIN` and `MAX`
* Miscellaneous code changes and lints



## [0.9.0](https://github.com/Blobfolio/dactyl/releases/tag/v0.9.0) - 2024-12-07

### New
Expand Down
4 changes: 2 additions & 2 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project Dependencies
Package: dactyl
Version: 0.9.0
Generated: 2024-12-07 19:06:40 UTC
Version: 0.9.1
Generated: 2025-01-09 17:45:24 UTC

This project has no dependencies.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dactyl"
version = "0.9.0"
version = "0.9.1"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
rust-version = "1.83"
Expand All @@ -25,7 +25,7 @@ default-target = "x86_64-unknown-linux-gnu"
name = "Dactyl"

[dev-dependencies]
brunch = "0.7.*"
brunch = "0.8.*"
fastrand = "2"
num-format = "0.4.*"

Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl fmt::Display for AnyNum {
// too small for separators.
let mut out = match self {
Self::Unsigned(n) =>
if 1000.gt(n) { return write!(f, "{n}"); }
if *n < 1000 { return write!(f, "{n}"); }
else { n.to_string() },
Self::Signed(n) =>
if (-999..1000).contains(n) { return write!(f, "{n}"); }
Expand Down Expand Up @@ -221,7 +221,7 @@ fn build_impls() -> String {
wrt!(out, i128, u8, u16, u32, u64, u128, i8, i16, i32, i64 );

// Noop casts.
wrt_self!(out, u8, u16, u32, u64, u128, i8, i16, i32, i64, i128);
wrt_self!(out, u8, u16, u32, u64, u128, i8, i16, i32, i64, i128);

// Write cfg-gated modules containing all of the sized implementations for
// a given pointer width. Thankfully we only have to enumerate the into
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ But the niceness doesn't stop there. Dactyl provides several other structs, meth
unused_import_braces,
)]

#![expect(clippy::module_name_repetitions, reason = "Repetition is preferred.")]
#![expect(clippy::redundant_pub_crate, reason = "Unresolvable.")]


Expand Down
23 changes: 10 additions & 13 deletions src/nice_int/nice_percent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,14 @@ macro_rules! nice_from {
#[expect(clippy::integer_division, reason = "We want this.")]
impl From<$float> for NicePercent {
fn from(num: $float) -> Self {
// Shortcut for overflowing values.
if num <= 0.0 || ! num.is_normal() { return Self::MIN; }
else if 1.0 <= num { return Self::MAX; }
// Treat NaN as zero.
if num.is_nan() { return Self::MIN; }

// We can maintain precision better by working from an integer.
// We know there is no existing integer part, so at most we'll
// wind up with four digits, which fits nicely in a u16.
let whole = (num * 10_000.0).round() as u16;
// Clamp and multiply by the desired precision.
let whole = (num.clamp(0.0, 1.0) * 10_000.0).round() as u16;

// Recheck the boundaries because of the rounding.
// Manually handle the edges.
if whole == 0 { return Self::MIN; }
else if 9999 < whole { return Self::MAX; }

Expand Down Expand Up @@ -203,15 +201,14 @@ impl NicePercent {
/// assert_eq!(num.as_str(), "33.40%");
/// ```
pub fn replace(&mut self, num: f32) {
if num <= 0.0 || ! num.is_normal() { return self.reset_min(); }
else if 1.0 <= num { return self.reset_max(); }
// Treat NaN as zero.
if num.is_nan() { return self.reset_min(); }

// We can maintain precision better by working from an integer.
// We know there is no existing integer part, so at most we'll
// wind up with four digits, which fits nicely in a u16.
let whole = (num * 10_000.0).round() as u16;
// Clamp and multiply by the desired precision.
let whole = (num.clamp(0.0, 1.0) * 10_000.0).round() as u16;

// Recheck the boundaries because of the rounding.
// Manually handle the edges.
if whole == 0 { return self.reset_min(); }
else if 9999 < whole { return self.reset_max(); }

Expand Down

0 comments on commit 0e37dba

Please sign in to comment.