Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.