如何在文档中找到可用于 &str 的 to_string? [英] How to find in documentation that to_string is available for &str?

查看:28
本文介绍了如何在文档中找到可用于 &str 的 to_string?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解 阅读一行,但我在str,即使我知道它在那里.

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.

推荐答案

&strToString::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.

(移自评论).

这篇关于如何在文档中找到可用于 &amp;str 的 to_string?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆