Hacker News new | past | comments | ask | show | jobs | submit login

So my first thought was "hey, why doesn't it take AsRef instead?" Then I checked the rust playground and... AsRef is not available for simple numbers, which I find confusing - since you can always reference an int, why isn't it?



I guess the same reason that `impl AsRef<T> for T` isn't implemented. (Not sure exactly what that is, but that would probably be a better question to look into, since you could argue that `AsRef<T>` should be manually implemented for any std type T with your argument)


I don’t think they’re related. The blanket AsRef<T> impl doesn’t exist because that would prevent you for providing different behavior (or blocking this behavior) for any of your types (eg smart pointers/containers) because rust doesn’t yet have impl specialization or override.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: