struct FlashBool(u8); breaks zerocopy_derive::IntoBytes with "expected bool because of return type in this derive macro expansion"
#2642
Closed
kairoswater-jason
started this conversation in
General
Replies: 1 comment 5 replies
-
|
After some digging, it looks like I wrote this type because an external API requires FromBytes (rather than TryFromBytes), with precludes the use of bool. In this case a u8 where 0 is false and 1-255 is true is what is needed. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've got a custom type called
struct FlashBool(u8);that implementsFrom<bool>,Into<bool>, andPartialEq<bool>When I try to use it in another struct called
DebugModethat derives the usual zerocopy traits, it produces the following error:below is the full definition of FlashBool
Here are my questions:
(1) am I violating some rule or expectation that the derive proc macros have?
(2) is there some easy workaround, other than just using an u8 (instead of FlashBool) and casting it to a bool at some later time someplace else.
Is there some good way to have a type similar to FlashBool in my DebugMode struct? (previously I was using a plain u8 to represent a bool, but it was cumbersome)
additional information from my cargo.lock file:
Beta Was this translation helpful? Give feedback.
All reactions