I tried to use a struct
from an external crate which does not use the pub
key.
I guess the best fix will be to open a PR but my curiosity get triggered here.
In C++ it is pretty easy. We can do:
#define private public
#include <...> // import public as public AND also private as public
#undef private
This will trick the compiler while parsing the code, so we get access to all the methods/fields of the class.
Any idea for Rust?
Here is a concrete example:
use warp::{
compression::{Compression, internal::CompressionProps},
reply::Response,
};
pub enum CompressionAlgorithms {
Brotli(Compression<dyn Fn(CompressionProps) -> Response>),
Deflate(Compression<dyn Fn(CompressionProps) -> Response>),
Gzip(Compression<dyn Fn(CompressionProps) -> Response>),
}
Compile error: error[E0603]: module `internal` is private
- in this example, we are trying to import a module and not a structure... Not sure if it changes anything.
Unfortunately, the docs for error E0603 is not really helpful if we do not own the crate. Same for the docs on visibility and privacy in the Rust Reference.