Skip to content

Commit

Permalink
release: 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Nov 28, 2024
2 parents f1b8e7a + f847069 commit 114abb6
Show file tree
Hide file tree
Showing 19 changed files with 281 additions and 141 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.8.0](https://github.com/Blobfolio/dactyl/releases/tag/v0.8.0) - 2024-11-28

### Changed

* Bump MSRV to `1.81`
* `NiceInflection::nice_inflect` now requires `&str` arguments instead of `AsRef<str>`;
* `NiceInflection::nice_inflect` now returns a `Display`-friendly wrapper instead of a `String` to avoid intermediary allocations;



## [0.7.4](https://github.com/Blobfolio/dactyl/releases/tag/v0.7.4) - 2024-09-15

### New
Expand Down
6 changes: 3 additions & 3 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project Dependencies
Package: dactyl
Version: 0.7.4
Generated: 2024-09-15 08:15:40 UTC
Version: 0.8.0
Generated: 2024-11-28 18:21:00 UTC

This package has no dependencies.
This project has no dependencies.
9 changes: 3 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "dactyl"
version = "0.7.4"
authors = ["Blobfolio, LLC. <hello@blobfolio.com>"]
version = "0.8.0"
authors = ["Josh Stoik <josh@blobfolio.com>"]
edition = "2021"
rust-version = "1.70"
rust-version = "1.81"
description = "A small library to quickly stringify integers with basic formatting."
license = "WTFPL"
repository = "https://github.com/Blobfolio/dactyl"
Expand All @@ -23,9 +23,6 @@ default-target = "x86_64-unknown-linux-gnu"

[package.metadata.bashman]
name = "Dactyl"
bash-dir = "./"
man-dir = "./"
credits-dir = "./"

[dev-dependencies]
brunch = "0.6.*"
Expand Down
26 changes: 1 addition & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,5 @@ Add `dactyl` to your `dependencies` in `Cargo.toml`, like:

```
[dependencies]
dactyl = "0.7.*"
dactyl = "0.8.*"
```



## License

See also: [CREDITS.md](CREDITS.md)

Copyright © 2024 [Blobfolio, LLC](https://blobfolio.com) &lt;[email protected]&gt;

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ macro_rules! wrt_self {


fn main() {
println!("cargo:rerun-if-env-changed=CARGO_PKG_VERSION");

// Make sure our formatting looks right.
assert_eq!(AnyNum::from(12345_u32).to_string(), "12_345", "Bug: Number formatting is wrong!");
assert_eq!(AnyNum::from(-12345_i32).to_string(), "-12_345", "Bug: Number formatting is wrong!");
Expand Down
6 changes: 3 additions & 3 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Dactyl: Hashing
*/

#![expect(clippy::cast_lossless, reason = "False positive.")]

use std::hash::{
BuildHasherDefault,
Hasher,
Expand Down Expand Up @@ -123,7 +125,6 @@ pub struct NoHasher(u64);
/// # Helper: Write Method(s) for Unsigned Ints.
macro_rules! write_unsigned {
($($fn:ident, $ty:ty),+ $(,)?) => ($(
#[allow(clippy::cast_lossless)] // "False positive."
#[inline]
#[doc = concat!("# Write `", stringify!($ty), "`")]
fn $fn(&mut self, val: $ty) {
Expand All @@ -136,8 +137,7 @@ macro_rules! write_unsigned {
/// # Helper: Write Method(s) for Signed Ints.
macro_rules! write_signed {
($($fn:ident, $ty1:ty, $ty2:ty),+ $(,)?) => ($(
#[allow(clippy::cast_lossless)] // False positive.
#[allow(clippy::cast_sign_loss)] // False positive.
#[expect(clippy::cast_sign_loss, reason = "False positive.")]
#[inline]
#[doc = concat!("# Write `", stringify!($ty1), "`")]
fn $fn(&mut self, val: $ty1) {
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ But the niceness doesn't stop there. Dactyl provides several other structs, meth
*/

#![deny(
// TODO: clippy::allow_attributes_without_reason,
clippy::allow_attributes_without_reason,
clippy::correctness,
unreachable_pub,
unsafe_code,
Expand All @@ -58,7 +58,7 @@ But the niceness doesn't stop there. Dactyl provides several other structs, meth
clippy::perf,
clippy::style,
// TODO: clippy::allow_attributes,
clippy::allow_attributes,
clippy::clone_on_ref_ptr,
clippy::create_dir,
clippy::filetype_is_file,
Expand Down Expand Up @@ -92,8 +92,8 @@ But the niceness doesn't stop there. Dactyl provides several other structs, meth
unused_import_braces,
)]

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



Expand Down Expand Up @@ -147,8 +147,8 @@ const DOUBLE: [[u8; 2]; 100] = [
pub(crate) const fn double(idx: usize) -> [u8; 2] { DOUBLE[idx] }

#[inline]
#[allow(clippy::cast_possible_truncation)] // False positive.
#[allow(clippy::integer_division)] // We want this.
#[expect(clippy::cast_possible_truncation, reason = "False positive.")]
#[expect(clippy::integer_division, reason = "We want this.")]
/// # Triple Digits.
///
/// Return both digits, ASCII-fied.
Expand Down
17 changes: 10 additions & 7 deletions src/nice_elapsed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl fmt::Display for NiceElapsed {
impl Eq for NiceElapsed {}

impl From<Duration> for NiceElapsed {
#[allow(clippy::cast_possible_truncation)] // False positive.
#[expect(clippy::cast_possible_truncation, reason = "False positive.")]
fn from(src: Duration) -> Self {
let s = src.as_secs();
let ms =
Expand Down Expand Up @@ -198,7 +198,7 @@ impl NiceElapsed {
}
}

#[allow(clippy::cast_possible_truncation)] // False positive.
#[expect(clippy::cast_possible_truncation, reason = "False positive.")]
#[must_use]
/// # Time Chunks (with Days).
///
Expand Down Expand Up @@ -226,7 +226,7 @@ impl NiceElapsed {
(d, h, m, s)
}

#[allow(clippy::cast_possible_truncation)] // False positive.
#[expect(clippy::cast_possible_truncation, reason = "False positive.")]
#[must_use]
/// # Time Chunks.
///
Expand Down Expand Up @@ -284,7 +284,7 @@ impl NiceElapsed {
/// ```
pub fn as_bytes(&self) -> &[u8] { &self.inner[0..self.len] }

#[allow(unsafe_code)] // Content is ASCII.
#[expect(unsafe_code, reason = "Content is ASCII.")]
#[must_use]
#[inline]
/// # As Str.
Expand All @@ -308,9 +308,12 @@ impl NiceElapsed {
}

impl NiceElapsed {
#[allow(clippy::cast_possible_truncation)] // False positive.
#[allow(clippy::many_single_char_names)] // Consistency is preferred.
#[allow(clippy::similar_names)] // Consistency is preferred.
#[expect(clippy::cast_possible_truncation, reason = "False positive.")]
#[expect(
clippy::many_single_char_names,
clippy::similar_names,
reason = "Consistency is preferred.",
)]
/// # From DHMS.ms.
///
/// Build with days, hours, minutes, seconds, and milliseconds (hundredths).
Expand Down
4 changes: 2 additions & 2 deletions src/nice_int/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl<const S: usize> NiceWrapper<S> {
/// Return the value as a byte string.
pub fn as_bytes(&self) -> &[u8] { &self.inner[self.from..] }

#[allow(unsafe_code)] // Content is ASCII.
#[expect(unsafe_code, reason = "Content is ASCII.")]
#[must_use]
#[inline]
/// # As Str.
Expand Down Expand Up @@ -203,7 +203,7 @@ macro_rules! nice_parse {
}

impl $nice {
#[allow(clippy::cast_possible_truncation)] // False positive.
#[expect(clippy::cast_possible_truncation, reason = "False positive.")]
/// # Parse.
fn parse(&mut self, mut num: $uint) {
for chunk in self.inner.rchunks_exact_mut(4) {
Expand Down
18 changes: 10 additions & 8 deletions src/nice_int/nice_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ macro_rules! inner {

/// `NiceFloat` provides a quick way to convert an `f32` or `f64` (up to
/// the absolute equivalent of `u64::MAX`) into a formatted byte string for
/// e.g. printing. Commas are added for every (integer) thousand; decimals are
/// e.g. printing.
///
/// Commas are added for every (integer) thousand; decimals are
/// rounded up to the nearest eight digits using a tie-to-even strategy.
///
/// Absolute values larger than `u64::MAX` will print as either
Expand Down Expand Up @@ -326,7 +328,7 @@ impl NiceFloat {
out
}

#[allow(unsafe_code)] // Content is ASCII.
#[expect(unsafe_code, reason = "Content is ASCII.")]
#[inline]
#[must_use]
/// # Compact String.
Expand Down Expand Up @@ -396,7 +398,7 @@ impl NiceFloat {
else { self.as_bytes() }
}

#[allow(unsafe_code)] // Content is ASCII.
#[expect(unsafe_code, reason = "Content is ASCII.")]
#[inline]
#[must_use]
/// # Precise String.
Expand Down Expand Up @@ -451,7 +453,7 @@ impl NiceFloat {
)
}

#[allow(clippy::cast_possible_truncation)] // False positive.
#[expect(clippy::cast_possible_truncation, reason = "False positive.")]
/// # Parse Top.
///
/// Write the integer portion of the value. This works the same way as
Expand Down Expand Up @@ -498,7 +500,7 @@ impl NiceFloat {
}
}

#[allow(clippy::integer_division)] // We want this.
#[expect(clippy::integer_division, reason = "We want this.")]
/// # Parse Bottom.
///
/// This writes the fractional part of the float, if any.
Expand Down Expand Up @@ -623,7 +625,7 @@ impl From<f64> for FloatKind {



#[allow(clippy::integer_division)] // We want this.
#[expect(clippy::integer_division, reason = "We want this.")]
/// # Parse Finite `f32`
///
/// This parses a float (that is not NaN or infinite) into the appropriate
Expand Down Expand Up @@ -672,7 +674,7 @@ fn parse_finite_f32(num: f32) -> FloatKind {
else { FloatKind::Normal(top, bottom, num.is_sign_negative()) }
}

#[allow(clippy::integer_division)] // We want this.
#[expect(clippy::integer_division, reason = "We want this.")]
/// # Parse Finite `f64`
///
/// This parses a float (that is not NaN or infinite) into the appropriate
Expand Down Expand Up @@ -727,7 +729,7 @@ fn parse_finite_f64(num: f64) -> FloatKind {



#[allow(clippy::cast_possible_truncation)] // False positive.
#[expect(clippy::cast_possible_truncation, reason = "False positive.")]
/// # Round, Tie to Even.
///
/// Fractions are rounded on the ninth decimal place (to eight places).
Expand Down
9 changes: 6 additions & 3 deletions src/nice_int/nice_percent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ impl Default for NicePercent {
/// This code is identical for `f32` and `f64` types.
macro_rules! nice_from {
($($float:ty),+ $(,)?) => ($(
#[allow(clippy::cast_possible_truncation)] // It is what it is.
#[allow(clippy::cast_sign_loss)] // It is what it is.
#[allow(clippy::integer_division)] // We want this.
#[expect(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
reason = "It is what it is.",
)]
#[expect(clippy::integer_division, reason = "We want this.")]
impl From<$float> for NicePercent {
fn from(num: $float) -> Self {
// Shortcut for overflowing values.
Expand Down
6 changes: 3 additions & 3 deletions src/nice_int/nice_u16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ super::nice_default!(NiceU16, ZERO, SIZE);
super::nice_from_nz!(NiceU16, NonZeroU16);

impl From<u16> for NiceU16 {
#[allow(clippy::cast_possible_truncation)] // False positive.
#[allow(clippy::integer_division)] // We want this.
#[allow(clippy::many_single_char_names)] // Consistency is preferred.
#[expect(clippy::cast_possible_truncation, reason = "False positive.")]
#[expect(clippy::integer_division, reason = "We want this.")]
#[expect(clippy::many_single_char_names, reason = "Consistency is preferred.")]
fn from(num: u16) -> Self {
if 999 < num {
let (num, rem) = (num / 1000, num % 1000);
Expand Down
4 changes: 2 additions & 2 deletions src/nice_int/nice_u8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl NiceU8 {
/// ```
pub const fn as_bytes3(&self) -> &[u8] { &self.inner }

#[allow(unsafe_code)] // Content is ASCII.
#[expect(unsafe_code, reason = "Content is ASCII.")]
#[must_use]
#[inline]
/// # Double Digit Str.
Expand All @@ -149,7 +149,7 @@ impl NiceU8 {
unsafe { std::str::from_utf8_unchecked(self.as_bytes2()) }
}

#[allow(unsafe_code)] // Content is ASCII.
#[expect(unsafe_code, reason = "Content is ASCII.")]
#[must_use]
#[inline]
/// # Triple Digit Str.
Expand Down
5 changes: 3 additions & 2 deletions src/traits/btoi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Dactyl — Bytes to Signed.
*/

#![expect(clippy::cast_possible_truncation, reason = "False positive.")]

use crate::traits::BytesToUnsigned;
use std::{
cmp::Ordering,
Expand Down Expand Up @@ -44,8 +46,7 @@ pub trait BytesToSigned: Sized {
macro_rules! signed {
($ty:ty, $unsigned:ty, $min:literal, $max:literal) => (
impl BytesToSigned for $ty {
#[allow(clippy::cast_possible_truncation)] // False positive.
#[allow(clippy::cast_possible_wrap)] // False positive.
#[expect(clippy::cast_possible_wrap, reason = "False positive.")]
/// # Bytes to Signed.
fn btoi(src: &[u8]) -> Option<Self> {
match src.len() {
Expand Down
Loading

0 comments on commit 114abb6

Please sign in to comment.