In Rust, the methods of a trait inherit the visibility of the trait itself:
pub trait Foo<Arg> {
pub(self) fn foo(&self, arg: Arg);
/* other public methods */
}
error[E0449]: unnecessary visibility qualifier
--> src/lib.rs:7:3
|
7 | pub(self) fn foo(&self, arg: Arg);
| ^^^^^^^^^
At minimum, we should hide this method from our documentation:
pub trait Foo<Arg> {
#[doc(hidden)]
fn foo(&self, arg: Arg);
/* other public methods */
}
…but this doesn’t actually prevent outsiders from calling our method! Fortunately, there are at least three other patterns #[doc(hidden)]
can be combined with to make foo
externally unusable.