To make a Rust object inaccessible within the crate, but accessible to the public outside it, you can use the pub
keyword to make the object public, and then use the #[doc(hidden)]
attribute to hide it from the crate's documentation.
For example, to create a struct named MyStruct
that is only accessible from outside the crate, you would define it like this:
#[doc(hidden)]
struct MyStruct {
// ...
}
pub struct VisibleStruct {
// ...
}
In this example, MyStruct
is marked with #[doc(hidden)]
, which means that it will not be included in the crate's documentation, but it is still accessible to code outside the crate that imports it. On the other hand, VisibleStruct
is marked as pub
, which means that it is accessible both inside and outside the crate.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-02-06 11:00:00 +0000
Seen: 10 times
Last updated: Jan 11 '23
What are the Cordapp Certificates used for in terms of signing and interacting?
How can SSL be used with CqlSessionFactoryBean in Springboot Cassandra?
How to set up Database First configuration in Entity Framework 7 for MVC 6?
How can I address the issue of Content Security Policy blocking more than I had anticipated?
How do I resolve a 502 error when attempting to call an HTTPS REST API from an HTTP REST API?
What does borrowing or moving a value from `stdout` mean?