You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the ToSocketAddrs trait is meant only for bounds, and all methods are supposed to be implementation details. This is done by putting them methods on "private" super trait. However, due to the way bounds on generics works, these methods are accidentally available to users.
fnbound<T:ToSocketAddrs>(t:T){// But legal here, since T: ToSocketAddrs leaks the super trait methods
t.to_socket_addrs();}fnmain(){// Uncomment to see error//"127.0.0.1:0".to_socket_addrs();bound("127.0.0.1:0");}
The solution is to define a private Internal argument type that must also be passed, so a user will see a compilation error when trying to call t.to_socket_addrs(), since they didn't call t.to_socket_addrs(Internal), and can't!
The text was updated successfully, but these errors were encountered:
Currently the
ToSocketAddrs
trait is meant only for bounds, and all methods are supposed to be implementation details. This is done by putting them methods on "private" super trait. However, due to the way bounds on generics works, these methods are accidentally available to users.The solution is to define a private
Internal
argument type that must also be passed, so a user will see a compilation error when trying to callt.to_socket_addrs()
, since they didn't callt.to_socket_addrs(Internal)
, and can't!The text was updated successfully, but these errors were encountered: