Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find in documentation that to_string is available for &str?

Tags:

rust

I was trying to understand what's going on when reading a line, but I couldn't find that there is a method to_string in the documentation for str, even though I know it's there.

like image 461
rofrol Avatar asked Jan 15 '15 22:01

rofrol


1 Answers

There is no direct link between &str and ToString::to_string in the docs because ToString has a blanket implementation:

impl<T> ToString for T where T: Display, T: ?Sized

This means that ToString is implemented for any item that implements Display. &str does implement Display.

(Moved from a comment).

like image 50
2 revs Avatar answered Sep 21 '22 00:09

2 revs