Hacker News new | ask | show | jobs
by SkiFire13 43 days ago
The reason it works with `String` is because trait methods get priority over applying autoderef (which is needed to go from `&String` to `&str` and select `str::strip_suffix`). If you however already have a `&str` then autoderef won't be needed and the inherent method will win over the trait method. At no point does the prelude come into play
1 comments

Not technically. But that's not the issue. The issue is that trait resolution and imports are treated inconsistently and that is a mistake.

Compare to [this](https://play.rust-lang.org/?version=stable&mode=debug&editio...)