From fa5e8d057541affcdee7678034e8727e60d8840c Mon Sep 17 00:00:00 2001 From: Lenovo <2281983669@qq.com> Date: Thu, 6 Jul 2023 11:55:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=8A=A8=E6=80=81=E6=95=B0=E7=BB=84=20Vect?= =?UTF-8?q?or):=20=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/basic/collections/vector.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/collections/vector.md b/src/basic/collections/vector.md index 4f3682a3..32fc0f92 100644 --- a/src/basic/collections/vector.md +++ b/src/basic/collections/vector.md @@ -384,7 +384,7 @@ fn main() { 执行输出 ``` -[Person { age: 1, name: "John" }, Person { age: 25, name: "John" }, Person { age: 25, name: "Zoe" }, Person { age: 30, name: "Al" }, Person { age: 60, name: "Al" }] +[Person { name: "Al", age: 30 }, Person { name: "Al", age: 60 }, Person { name: "John", age: 1 }, Person { name: "John", age: 25 }, Person { name: "Zoe", age: 25 }] ``` 需要 `derive` `Ord` 相关特性,需要确保你的结构体中所有的属性均实现了 `Ord` 相关特性,否则会发生编译错误。`derive` 的默认实现会依据属性的顺序依次进行比较,如上述例子中,当 `Person` 的 `name` 值相同,则会使用 `age` 进行比较。