3 ms·
Oh, yes of course. Switching to String and it works as I expected. I thought the builtins were defined in core and reexported by the prelude (they are defined
by 3836293648 6mo ago
Oh, yes of course. Switching to String and it works as I expected.
I thought the builtins were defined in core and reexported by the prelude (they are defined in core, they're just implicitly in scope anyway).
But I still think expected behaviour is that builtins should have the same precedence as the prelude.
- SkiFire13 6mo agoThe 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
- 3836293648 6mo agoNot 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&edition=2024&gist=29066c28ff506af52f5446b4efc76297 https://play.rust-lang.org/?version=stable&mode=debug&editio...)