如何在文档中找到可用于 &str 的 to_string? [英] How to find in documentation that to_string is available for &str?
本文介绍了如何在文档中找到可用于 &str 的 to_string?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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.
推荐答案
&str
和 ToString::to_string
在文档中,因为 ToString
有一个 blanket 实现:
impl<T> ToString for T where T: Display, T: ?Sized
这意味着 ToString
是为任何实现 显示
.&str
确实实现了 Display
.
This means that ToString
is implemented for any item that implements Display
. &str
does implement Display
.
(移自评论).
这篇关于如何在文档中找到可用于 &str 的 to_string?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文