|
31 | 31 | - [`str::as_bytes()`](https://doc.rust-lang.org/std/primitive.str.html#method.as_bytes)
|
32 | 32 | 用于查看 UTF-8 字节的 `str` 切片,这是无内存代价的(不会产生内存分配)。 传入值是 `&str` 类型,输出值是 `&[u8]` 类型。
|
33 | 33 | - `to_`
|
34 |
| - - [`Path::to_str`] (https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.to_str) |
| 34 | + - [`Path::to_str`](https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.to_str) |
35 | 35 | 对操作系统路径进行 UTF-8 字节检查,开销昂贵。
|
36 | 36 | 虽然输入和输出都是借用,但是这个方法对运行时产生不容忽视的代价,
|
37 | 37 | 所以不应使用 `as_str` 名称。
|
38 |
| - - [`str::to_lowercase()`] (https://doc.rust-lang.org/std/primitive.str.html#method.to_lowercase) |
| 38 | + - [`str::to_lowercase()`](https://doc.rust-lang.org/std/primitive.str.html#method.to_lowercase) |
39 | 39 | 生成正确的 Unicode 小写字符,
|
40 | 40 | 涉及遍历字符串的字符,可能需要分配内存。
|
41 | 41 | 输入值是 `&str` 类型,输出值是 `String` 类型。
|
42 |
| - - [`f64::to_radians()`] (https://doc.rust-lang.org/std/primitive.f64.html#method.to_radians) |
| 42 | + - [`f64::to_radians()`](https://doc.rust-lang.org/std/primitive.f64.html#method.to_radians) |
43 | 43 | 把浮点数的角度制转换成弧度制。
|
44 | 44 | 输入和输出都是 `f64` 。没必要传入 `&f64` ,因为复制 `f64` 花销很小。
|
45 | 45 | 但是使用 `into_radians` 名称就会具有误导性,因为输入数据没有被消耗。
|
46 | 46 | - `into_`
|
47 | 47 | - [`String::into_bytes()`](https://doc.rust-lang.org/std/string/struct.String.html#method.into_bytes)
|
48 | 48 | 从 `String` 提取出背后的 `Vec<u8>` 数据,这是无代价的。
|
49 | 49 | 它转移了 `String` 的所有权,然后返回具有所有权的 `Vec<u8>` 。
|
50 |
| - - [`BufReader::into_inner()`] (https://doc.rust-lang.org/std/io/struct.BufReader.html#method.into_inner) |
| 50 | + - [`BufReader::into_inner()`](https://doc.rust-lang.org/std/io/struct.BufReader.html#method.into_inner) |
51 | 51 | 转移了 buffered reader 的所有权,取出其背后的 reader ,这是无代价的。
|
52 | 52 | 存于缓冲区的数据被丢弃了。
|
53 |
| - - [`BufWriter::into_inner()`] (https://doc.rust-lang.org/std/io/struct.BufWriter.html#method.into_inner) |
| 53 | + - [`BufWriter::into_inner()`](https://doc.rust-lang.org/std/io/struct.BufWriter.html#method.into_inner) |
54 | 54 | 转移了 buffered writer 的所有权,取出其背后的 writer ,这可能以很大的代价刷新所有缓存数据。
|
55 | 55 |
|
56 | 56 | 如果类型转换方法返回的类型具有 `mut` 修饰,那么这个方法的名称应如同返回类型组成部分的顺序那样,带有 `mut` 。
|
|
68 | 68 |
|
69 | 69 | | lint name | Clippy 可检测 | Rustc 可检测 | Lint Group | Lint Level |
|
70 | 70 | | ------ | ---- | --------- | ------ | ------ |
|
71 |
| -| [wrong_self_convention](https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention) | yes| no | Style | warn | |
| 71 | +| [wrong_self_convention](https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention) | yes| no | Style | warn | |
0 commit comments