Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update string.md #194

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/conversion/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() {

## 解析字符串

我们经常需要把字符串转成数字。完成这项工作的标准手段是用 [`parse`] 函数。我们得提供要转换到的类型,这可以通过不使用类型推断,或者用 “涡轮鱼” 语法(turbo fish,`<>`)实现。
我们经常需要把字符串转成数字。完成这项工作的标准手段是用 [`parse`] 函数。我们得提供要转换到的类型,这可以通过使用类型推断,或者用 “涡轮鱼” 语法(turbo fish,`<>`)实现。

只要对目标类型实现了 [`FromStr`] trait,就可以用 `parse` 把字符串转换成目标类型。
标准库中已经给无数种类型实现了 `FromStr`。如果要转换到用户定义类型,只要手动实现
Expand Down