I have two types: A and B.
Both types implement a private method: fn private(&self) {}
Both types should be accepted by a public function: pub fn public(letter: A or B) {}
The implementation of public requires access to the private method.
How to type this?
To capture that the argument to public is A or B, both types could be marked with a public trait, Letter.
To capture that the argument to public implements private, both types could implement a private trait, but then this private trait would be leaked by the public function.
The argument must be constrained privately to reflect the private method, but it seems any constraint on the argument of a public function must be a public constraint...
If simple traits like this won't work, what will?
Yes, that's an option but a bit inconvenient, as it'd be nice to pass the types directly to the public function without asking library users to first wrap them (in an enum).
Jack Wrenn has a block post on how to "simulate" private trait methods with something called sealed traits.
I personally find this a little bit hacky. There is probably a good reason (maybe even rooted in the HM type system itself), why trait methods inherit the visibility of the trait itself, but I don't know why.
The standard library of course cheats as it has the power to (ab-)use the mechanism of unstable standard library API (besides the obvious hiding the documentation part) to fully hide its private trait methods such as this one.