You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using PackedStruct on private structs results in an error:
error[E0446]: private type `FooPacked` in public interface
--> lib/foo.rs:13:10
|
13 | #[derive(PackedStruct)]
| ^^^^^^^^^^^^ can't leak private type
14 | #[packed_struct(endian = "msb", bit_numbering = "msb0")]15 | struct FooPacked{
| - `FooPacked` declared asprivate
|
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info
Is it possible to make it usable on private (and pub(crate)) structs too?
Environment:
Rust 1.46.0
packed_struct 0.3.0
The text was updated successfully, but these errors were encountered:
pub(crate) didn't exist back then, so a bunch of things will have to be upgraded for this to work, but yes, for now, everything has to be public. You can always declare your module as private and your lib won't export these types.
From looking at the source code, it seems the only reason why this error occurs is because this code creates a pub function using the type. But that function is only used in one place, so simply removing the pub or declaring the function inside of the other function gets rid of this error and allows deriving on structs with any visibility.
Using PackedStruct on private structs results in an error:
Is it possible to make it usable on private (and
pub(crate)
) structs too?Environment:
The text was updated successfully, but these errors were encountered: