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

Yes. It's a design bug that String and slice don't share a common trait and that `.as_slice()` is common simply to use slice methods.

I expect that to be fixed before 1.0.




At least you can now do: foo[].some_slice_method()


I think this is an anti-pattern. I'm not a fan of the slicing syntax in general, which seems to exist only to paper over the missing traits that wycats mentions.


We will almost certainly just have `Deref<str> for String` and so autoderef will handle `some_string.some_slice_method()` correctly.


Will we be able to kill the slicing syntax, then? :)


Slicing syntax is about being able to do stuff like string[1:3] AFAIK, so I hope it won't get killed.




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

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

Search: