Skip to content

Derive-crate cleanups from review#8

Merged
lthiery merged 2 commits into
rust-2024from
derive-cleanups
Jul 7, 2026
Merged

Derive-crate cleanups from review#8
lthiery merged 2 commits into
rust-2024from
derive-cleanups

Conversation

@lthiery

@lthiery lthiery commented Jul 7, 2026

Copy link
Copy Markdown
Owner
  • Overflow safety: the unit constructors (kb(), mib(), …) now use checked_mul and panic with a clear message instead of silently wrapping in release builds. ByteScale::pb(20_000) used to return garbage; now it panics in both debug and release (regression test included, verified in --release). In const contexts the panic becomes a compile error, which is strictly an improvement.
  • Derive refactor: #[derive(HumanByte)] parsed its input once per sub-derive and round-tripped everything through strings (format! on five TokenStreams, then re-parse). It now parses once and composes proc_macro2::TokenStreams directly. Generated code is identical; all tests pass unchanged.
  • Docs/typos: range_stop doc said "explicit lower bound" (it sets the upper bound); ByteSizeVistorByteSizeVisitor.

lthiery added 2 commits July 7, 2026 18:41
- HumanByte derive now parses the input once and composes
  proc_macro2::TokenStreams directly instead of round-tripping every
  sub-derive through strings and re-parsing five times
- unit constructors (kb, mib, ...) use checked_mul and panic on
  overflow instead of silently wrapping in release builds; documented
  and covered by a release-mode-verified regression test
- fix range_stop doc (said lower bound, is upper bound) and the
  ByteSizeVistor -> ByteSizeVisitor typo
Stacked PRs (base = another feature branch) were getting no CI at all
because of the pull_request branches filter.
@lthiery lthiery merged commit cb7d5e0 into rust-2024 Jul 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant