-
Notifications
You must be signed in to change notification settings - Fork 121
[macros] Support shrinking value transmutes #2581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0dc4ac5
to
5f19ed9
Compare
df3a207
to
15f9941
Compare
@@ -51,39 +51,109 @@ | |||
/// This macro can be invoked in `const` contexts. | |||
#[macro_export] | |||
macro_rules! transmute { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to document allow(shrink)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
c18affd
to
50bb997
Compare
In `transmute!`, support an `#![allow(shrink)]` attribute which is invoked as follows: transmute!(#![allow(shrink)] src); When this attribute is provided, `transmute!` will permit shrinking transmutes, in which the destination value may be smaller than the source value. Co-authored-by: Jack Wrenn <[email protected]> gherrit-pr-id: I46b18b4b1d10507b7e1d2e01b09dc4960cfcdce1
50bb997
to
8e4a6e5
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2581 +/- ##
==========================================
- Coverage 88.91% 88.72% -0.19%
==========================================
Files 20 20
Lines 5312 5332 +20
==========================================
+ Hits 4723 4731 +8
- Misses 589 601 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Jack Wrenn <[email protected]>
In
transmute!
, support an#![allow(shrink)]
attribute which isinvoked as follows:
transmute!(#![allow(shrink)] src);
When this attribute is provided,
transmute!
will permit shrinkingtransmutes, in which the destination value may be smaller than the
source value.
Co-authored-by: Jack Wrenn [email protected]
This PR is on branch transmute-ref-dst.