Merge pull request #1338 from nicong622/patch-1

避免语句不够通顺的问题
pull/1344/head
Sunface 10 months ago committed by GitHub
commit 0f02127594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -498,7 +498,7 @@ string_clear = ""
1、使用 `+` 或者 `+=` 连接字符串 1、使用 `+` 或者 `+=` 连接字符串
使用 `+` 或者 `+=` 连接字符串要求右边的参数必须为字符串的切片引用Slice类型。其实当调用 `+` 的操作符时,相当于调用了 `std::string` 标准库中的 [`add()`](https://doc.rust-lang.org/std/string/struct.String.html#method.add) 方法,这里 `add()` 方法的第二个参数是一个引用的类型。因此我们在使用 `+` 必须传递切片引用类型。不能直接传递 `String` 类型。**`+` 是返回一个新的字符串,所以变量声明可以不需要 `mut` 关键字修饰**。 使用 `+` 或者 `+=` 连接字符串要求右边的参数必须为字符串的切片引用Slice类型。其实当调用 `+` 的操作符时,相当于调用了 `std::string` 标准库中的 [`add()`](https://doc.rust-lang.org/std/string/struct.String.html#method.add) 方法,这里 `add()` 方法的第二个参数是一个引用的类型。因此我们在使用 `+` 必须传递切片引用类型。不能直接传递 `String` 类型。**`+` 是返回一个新的字符串,所以变量声明可以不需要 `mut` 关键字修饰**。
示例代码如下: 示例代码如下:

Loading…
Cancel
Save