Sorry for the late response! Unfortunately, we cannot currently add such a restriction, because:
-
Borrow has a blanket implementation T: Borrow<T> for all T, which is really important for its use cases;
-
AsRef has a different blanket implementation, important for its use cases;
- We can’t have both blanket implementations at once, due to coherence limitations.
In the future, if we get impl specialization, we can probably provide a blanket implementation of AsRef for anything implementing Borrow, which would have a similar effect (and even guarantee that the two impls do the same thing). That can happen post-1.0.