Skip to content

Add zerofrom::transparent! macro#7788

Draft
sffc wants to merge 1 commit intounicode-org:mainfrom
sffc:zf-macro-rules
Draft

Add zerofrom::transparent! macro#7788
sffc wants to merge 1 commit intounicode-org:mainfrom
sffc:zf-macro-rules

Conversation

@sffc
Copy link
Copy Markdown
Member

@sffc sffc commented Mar 18, 2026

Latest attempt at #7607

Looking for feedback on the general approach, and then on the concrete implementation.

Changelog

zerofrom: Adds macro to derive ZeroFrom and concrete functions for repr(transparent) conversions

  • New macro: zerofrom::transparent!

@sffc sffc requested a review from Manishearth as a code owner March 18, 2026 15:03
@sffc sffc mentioned this pull request Mar 18, 2026
Copy link
Copy Markdown
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In favor of the general implementation. I think the way you handle method docs/pub/etc is clever.

This is exactly along the lines as what I was envisioning for transparent casts for a long time, and is significantly better than my imagined level of complexity.

@sffc sffc marked this pull request as draft March 19, 2026 20:41
@sffc
Copy link
Copy Markdown
Member Author

sffc commented Mar 19, 2026

Thanks; if this direction looks good to you then I'll clean up this PR and get it ready for merging.

/// Implements [`ZeroFrom`](crate::ZeroFrom) on a transparent type
/// from a reference to the inner type.
///
/// Also supports creating concrete functions.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
/// Also supports creating concrete functions.
/// Also supports adding concrete conversion functions between various reference types.

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.

2 participants