-
Notifications
You must be signed in to change notification settings - Fork 107
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
Enforce Src: FromBytes
in try_transmute_mut!
#2229
Conversation
69ad562
to
2bf3099
Compare
(Have a killer headache tonight; I'll finish this up first thing tomorrow.) |
2bf3099
to
4fdd646
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v0.8.x #2229 +/- ##
==========================================
+ Coverage 87.42% 87.46% +0.04%
==========================================
Files 16 16
Lines 6115 6136 +21
==========================================
+ Hits 5346 5367 +21
Misses 769 769 ☔ View full report in Codecov by Sentry. |
4fdd646
to
cc95f58
Compare
src/macros.rs
Outdated
@@ -577,7 +577,7 @@ macro_rules! try_transmute_ref { | |||
/// ```ignore | |||
/// fn try_transmute_mut<Src, Dst>(src: &mut Src) -> Result<&mut Dst, ValidityError<&mut Src, Dst>> | |||
/// where | |||
/// Src: IntoBytes, | |||
/// Src: FromByte + IntoBytes, |
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.
/// Src: FromByte + IntoBytes, | |
/// Src: FromBytes + IntoBytes, |
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.
src/macros.rs
Outdated
let array_of_bools = &mut [false, true, false, true, false, true, false, true]; | ||
let array_of_arrays = &mut [[0u8, 1], [0, 1], [0, 1], [0, 1]]; | ||
let x: Result<&mut [[u8; 2]; 4], _> = try_transmute_mut!(array_of_bools); | ||
assert_eq!(x, Ok(array_of_arrays)); |
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.
Can we keep this test and use u8
instead of bool
?
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.
Ensures that the source reference remains valid after the transmuted (and possibly mutated) destination is dropped. Makes progress on #2226
cc95f58
to
018a552
Compare
Ensures that the source reference remains valid after the transmuted (and possibly mutated) destination is dropped.
Makes progress on #2226