What is the best way to use include_bytes! and give the resulting binary blob a specific alignment? For example if the blob contains a bunch of C structs, or any other number of reasons.
Is there a more clean way to achieve what I've done with this hack, beyond just hiding it with a macro?
struct Wrapper([u8; include_bytes!("file").len()]);
const MY_DATA: &[u8] = &Wrapper(*include_bytes!("file")).0;
I'd imagine the double include_bytes! is not great for build times either...
Ah, that would work indeed! Thank you
Yes AFAIK there still is no cleaner way than that, at least it avoids the double
I've added a macro to the prior linked comment which encapsulates the construction of the static to keep things even cleaner.
(I still don't think it's big enough to be worth publishing and maintaining a crate for it, though!)
Edit: Actually, now that I'm thinking about it, maybe it's worth having a crate for, just for discoverability.
Thanks, just switched to that, that's perfect!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.