I have two types, each of which contains many supporting functions; all content of these two types must be private (in my case, they are mutable pointers to objects in C). These two types are conceptually different, so I put them in different modules ...
pub mod client {
pub struct Client {
}
}
pub mod collection {
pub struct Collection {
}
}
(In my real case, mod clientthey mod collectionare separate files, i.e., client.rsand collection.rs.)
client.rsneed to create Collection; however, he cannot, since the internal ones are private. Any attempt to write a function has the same problem: the function must be in collection.rs(for access to private members Collection, but it must be pubin order client.rsto access it ... but now it is also pubfor the whole world.
, , - "" . ( pub API, .)