Skip to content

Commit

Permalink
release: 0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed May 20, 2024
2 parents d6d46fa + b44c843 commit f30ed89
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
RUSTFLAGS: "-D warnings"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/msrv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
RUSTFLAGS: "-D warnings"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@



## [0.7.1](https://github.com/Blobfolio/dactyl/releases/tag/v0.7.1) - 2024-05-19

### Changed

* Add various `#[inline]` hints to improve downstream optimization passes.



## [0.7.0](https://github.com/Blobfolio/dactyl/releases/tag/v0.7.0) - 2024-02-08

### Removed
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.7.0
Generated: 2024-02-08 18:09:02 UTC
Version: 0.7.1
Generated: 2024-05-20 02:21:12 UTC

This package has no dependencies.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dactyl"
version = "0.7.0"
version = "0.7.1"
authors = ["Blobfolio, LLC. <[email protected]>"]
edition = "2021"
rust-version = "1.70"
Expand Down
5 changes: 4 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ macro_rules! wrt {
&mut $out,
concat!(
"impl SaturatingFrom<", stringify!($from), "> for ", stringify!($to), "{{\n",
"\t#[inline]\n",
"\t#[doc = \"", "# Saturating From `", stringify!($from), "`\"]\n",
"\t#[doc = \"\"]\n",
"\t#[doc = \"", "This method will safely recast any `", stringify!($from), "` into a `", stringify!($to), "`, clamping the values to `", stringify!($to), "::MIN..=", stringify!($to), "::MAX` to prevent overflow or wrapping.", "\"]\n",
Expand All @@ -164,10 +165,10 @@ macro_rules! wrt_self {
&mut $out,
concat!(
"impl SaturatingFrom<Self> for ", stringify!($to), "{{\n",
"\t#[inline]",
"\t#[doc = \"# Saturating From `Self`\"]\n",
"\t#[doc = \"\"]\n",
"\t#[doc = \"`Self`-to-`Self` (obviously) requires no saturation; this implementation is a noop.\"]\n",
"\t#[inline]",
"\tfn saturating_from(src: Self) -> Self {{ src }}\n",
"}}",
),
Expand Down Expand Up @@ -233,6 +234,7 @@ mod sized {{
use super::SaturatingFrom;
impl<T: SaturatingFrom<{unsigned}>> SaturatingFrom<usize> for T {{
#[inline]
/// # Saturating From `usize`
///
/// This blanket implementation uses `{unsigned}` as a go-between, since it is equivalent to `usize`.
Expand All @@ -241,6 +243,7 @@ mod sized {{
}}
}}
impl<T: SaturatingFrom<{signed}>> SaturatingFrom<isize> for T {{
#[inline]
/// # Saturating From `isize`
///
/// This blanket implementation uses `{signed}` as a go-between, since it is equivalent to `isize`.
Expand Down
7 changes: 7 additions & 0 deletions src/nice_elapsed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ const SIZE: usize = 52;
macro_rules! as_ref_borrow_cast {
($($cast:ident $ty:ty),+ $(,)?) => ($(
impl AsRef<$ty> for NiceElapsed {
#[inline]
fn as_ref(&self) -> &$ty { self.$cast() }
}
impl ::std::borrow::Borrow<$ty> for NiceElapsed {
#[inline]
fn borrow(&self) -> &$ty { self.$cast() }
}
)+);
Expand All @@ -40,6 +42,7 @@ macro_rules! as_ref_borrow_cast {
macro_rules! elapsed_from {
($($type:ty),+) => ($(
impl From<$type> for NiceElapsed {
#[inline]
/// This will never fail, however large values will be capped to
/// [`u32::MAX`] before parsing, so may not reflect all the seconds
/// you hoped they would.
Expand Down Expand Up @@ -81,6 +84,7 @@ pub struct NiceElapsed {
}

impl AsRef<[u8]> for NiceElapsed {
#[inline]
fn as_ref(&self) -> &[u8] { self.as_bytes() }
}

Expand Down Expand Up @@ -142,10 +146,12 @@ impl From<Duration> for NiceElapsed {
}

impl From<Instant> for NiceElapsed {
#[inline]
fn from(src: Instant) -> Self { Self::from(src.elapsed()) }
}

impl From<u32> for NiceElapsed {
#[inline]
fn from(num: u32) -> Self {
// Nothing!
if 0 == num { Self::min() }
Expand All @@ -172,6 +178,7 @@ impl PartialEq for NiceElapsed {

impl NiceElapsed {
#[must_use]
#[inline]
/// # Minimum Value
///
/// We can save some processing time by hard-coding the value for `0`,
Expand Down
16 changes: 16 additions & 0 deletions src/nice_int/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ use std::{
macro_rules! as_ref_borrow_cast {
($($cast:ident $ty:ty),+ $(,)?) => ($(
impl<const S: usize> AsRef<$ty> for NiceWrapper<S> {
#[inline]
fn as_ref(&self) -> &$ty { self.$cast() }
}
impl<const S: usize> ::std::borrow::Borrow<$ty> for NiceWrapper<S> {
#[inline]
fn borrow(&self) -> &$ty { self.$cast() }
}
)+);
Expand All @@ -51,6 +53,7 @@ pub struct NiceWrapper<const S: usize> {
}

impl<const S: usize> AsRef<[u8]> for NiceWrapper<S> {
#[inline]
fn as_ref(&self) -> &[u8] { self.as_bytes() }
}

Expand All @@ -66,10 +69,12 @@ impl<const S: usize> fmt::Debug for NiceWrapper<S> {

impl<const S: usize> Deref for NiceWrapper<S> {
type Target = [u8];
#[inline]
fn deref(&self) -> &Self::Target { self.as_bytes() }
}

impl<const S: usize> fmt::Display for NiceWrapper<S> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
Expand All @@ -78,33 +83,40 @@ impl<const S: usize> fmt::Display for NiceWrapper<S> {
impl<const S: usize> Eq for NiceWrapper<S> {}

impl<const S: usize> From<NiceWrapper<S>> for String {
#[inline]
fn from(src: NiceWrapper<S>) -> Self { src.as_str().to_owned() }
}

impl<const S: usize> From<NiceWrapper<S>> for Vec<u8> {
#[inline]
fn from(src: NiceWrapper<S>) -> Self { src.as_bytes().to_vec() }
}

impl<const S: usize, T> From<Option<T>> for NiceWrapper<S>
where Self: From<T> + Default {
#[inline]
/// `None` is treated like zero, otherwise this will simply unwrap the
/// inner value and run `From` against that.
fn from(num: Option<T>) -> Self { num.map_or_else(Self::default, Self::from) }
}

impl<const S: usize> Hash for NiceWrapper<S> {
#[inline]
fn hash<H: Hasher>(&self, state: &mut H) { state.write(self.as_bytes()) }
}

impl<const S: usize> Ord for NiceWrapper<S> {
#[inline]
fn cmp(&self, other: &Self) -> Ordering { self.as_bytes().cmp(other.as_bytes()) }
}

impl<const S: usize> PartialEq for NiceWrapper<S> {
#[inline]
fn eq(&self, other: &Self) -> bool { self.as_bytes() == other.as_bytes() }
}

impl<const S: usize> PartialOrd for NiceWrapper<S> {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
}

Expand Down Expand Up @@ -142,6 +154,7 @@ impl<const S: usize> NiceWrapper<S> {
macro_rules! nice_from_nz {
($nice:ty, $($nz:ty),+ $(,)?) => ($(
impl From<$nz> for $nice {
#[inline]
fn from(num: $nz) -> Self { Self::from(num.get()) }
}
)+);
Expand All @@ -152,10 +165,12 @@ macro_rules! nice_from_nz {
macro_rules! nice_default {
($nice:ty, $zero:expr, $size:ident) => (
impl Default for $nice {
#[inline]
fn default() -> Self { Self { inner: $zero, from: $size - 1 } }
}

impl $nice {
#[inline]
#[doc(hidden)]
#[must_use]
/// # Empty.
Expand All @@ -171,6 +186,7 @@ macro_rules! nice_default {
macro_rules! nice_parse {
($nice:ty, $uint:ty) => (
impl From<$uint> for $nice {
#[inline]
fn from(num: $uint) -> Self {
let mut out = Self::empty();
out.parse(num);
Expand Down
11 changes: 11 additions & 0 deletions src/nice_int/nice_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ macro_rules! inner {
pub type NiceFloat = NiceWrapper<SIZE>;

impl Default for NiceFloat {
#[inline]
fn default() -> Self {
Self {
inner: inner!(b','),
Expand All @@ -106,10 +107,12 @@ impl Default for NiceFloat {
}

impl From<f32> for NiceFloat {
#[inline]
fn from(num: f32) -> Self { Self::from(FloatKind::from(num)) }
}

impl From<f64> for NiceFloat {
#[inline]
fn from(num: f64) -> Self { Self::from(FloatKind::from(num)) }
}

Expand All @@ -132,6 +135,7 @@ impl From<FloatKind> for NiceFloat {

impl NiceFloat {
#[must_use]
#[inline]
/// # Infinity.
///
/// This returns an infinite instance! No distinction is made between
Expand Down Expand Up @@ -159,6 +163,7 @@ impl NiceFloat {
}

#[must_use]
#[inline]
/// # NaN.
///
/// This returns a not-a-number instance.
Expand All @@ -179,6 +184,7 @@ impl NiceFloat {
}

#[must_use]
#[inline]
/// # Overflow.
///
/// This is used for values with integer components that do not fit within
Expand Down Expand Up @@ -321,6 +327,7 @@ impl NiceFloat {
}

#[allow(unsafe_code)]
#[inline]
#[must_use]
/// # Compact String.
///
Expand Down Expand Up @@ -353,6 +360,7 @@ impl NiceFloat {
unsafe { std::str::from_utf8_unchecked(self.compact_bytes()) }
}

#[inline]
#[must_use]
/// # Precise Bytes.
///
Expand Down Expand Up @@ -388,6 +396,7 @@ impl NiceFloat {
}

#[allow(unsafe_code)]
#[inline]
#[must_use]
/// # Precise String.
///
Expand Down Expand Up @@ -593,6 +602,7 @@ pub enum FloatKind {
}

impl From<f32> for FloatKind {
#[inline]
fn from(num: f32) -> Self {
if num.is_nan() { Self::NaN }
else if num.is_infinite() { Self::Infinity }
Expand All @@ -601,6 +611,7 @@ impl From<f32> for FloatKind {
}

impl From<f64> for FloatKind {
#[inline]
fn from(num: f64) -> Self {
if num.is_nan() { Self::NaN }
else if num.is_infinite() { Self::Infinity }
Expand Down
4 changes: 4 additions & 0 deletions src/nice_int/nice_percent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const ZERO: [u8; SIZE] = [b'0', b'0', b'0', b'.', b'0', b'0', b'%'];
pub type NicePercent = NiceWrapper<SIZE>;

impl Default for NicePercent {
#[inline]
fn default() -> Self { Self::min() }
}

Expand Down Expand Up @@ -102,6 +103,7 @@ nice_from!(f32, f64);
impl<T: IntDivFloat> TryFrom<(T, T)> for NicePercent {
type Error = ();

#[inline]
/// # Percent From T/T.
///
/// This method is a shorthand that performs the (decimal) division of
Expand Down Expand Up @@ -129,6 +131,7 @@ impl<T: IntDivFloat> TryFrom<(T, T)> for NicePercent {
}

impl NicePercent {
#[inline]
#[must_use]
/// # Minimum value.
///
Expand All @@ -140,6 +143,7 @@ impl NicePercent {
}
}

#[inline]
#[must_use]
/// # Maximum value.
///
Expand Down
1 change: 1 addition & 0 deletions src/traits/btoi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ signed!(isize, u128, 170_141_183_460_469_231_731_687_303_715_884_105_728, 170_14
macro_rules! nonzero {
($($outer:ty, $inner:ty),+ $(,)?) => ($(
impl BytesToSigned for $outer {
#[inline]
/// # Bytes to Unsigned.
fn btoi(src: &[u8]) -> Option<Self> {
<$inner>::btoi(src).and_then(Self::new)
Expand Down
5 changes: 5 additions & 0 deletions src/traits/btou.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,21 +365,25 @@ impl BytesToUnsigned for u128 {
impl BytesToUnsigned for usize {
#[cfg(target_pointer_width = "16")]
#[must_use]
#[inline]
/// # Bytes to Unsigned.
fn btou(src: &[u8]) -> Option<Self> { u16::btou(src).map(Self::from) }

#[cfg(target_pointer_width = "32")]
#[must_use]
#[inline]
/// # Bytes to Unsigned.
fn btou(src: &[u8]) -> Option<Self> { Some(u32::btou(src)? as Self) }

#[cfg(target_pointer_width = "64")]
#[must_use]
#[inline]
/// # Bytes to Unsigned.
fn btou(src: &[u8]) -> Option<Self> { Some(u64::btou(src)? as Self) }

#[cfg(target_pointer_width = "128")]
#[must_use]
#[inline]
/// # Bytes to Unsigned.
fn btou(src: &[u8]) -> Option<Self> { Some(u128::btou(src)? as Self) }
}
Expand All @@ -389,6 +393,7 @@ impl BytesToUnsigned for usize {
macro_rules! nonzero {
($($outer:ty, $inner:ty),+ $(,)?) => ($(
impl BytesToUnsigned for $outer {
#[inline]
/// # Bytes to Unsigned.
fn btou(src: &[u8]) -> Option<Self> {
<$inner>::btou(src).and_then(Self::new)
Expand Down
Loading

0 comments on commit f30ed89

Please sign in to comment.