From 2446434a03e11d50d853ece268d9f3fa912e7132 Mon Sep 17 00:00:00 2001 From: Unisko PENG Date: Wed, 12 Apr 2023 14:39:58 +0800 Subject: [PATCH] Update Ch10 --- src/Ch10_Generic_Types_Traits_and_Lifetimes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ch10_Generic_Types_Traits_and_Lifetimes.md b/src/Ch10_Generic_Types_Traits_and_Lifetimes.md index 0571ad5..ec3fa0d 100644 --- a/src/Ch10_Generic_Types_Traits_and_Lifetimes.md +++ b/src/Ch10_Generic_Types_Traits_and_Lifetimes.md @@ -1,6 +1,6 @@ # 泛型、特质与生命周期 -每种编程语言都有着用于有效处理重复概念的一些工具。在 Rust 中,一种这样的工具就是 *泛型(generics)*:将一些具体类型或其他属性的替身抽象出来。对于在编译及运行代码时泛型处有着什么,咱们无需知悉就可以对泛型的行为,以及这些泛型与其他泛型之间的关系,进行表达(abstract stand-ins for concret types or other properties. We can express the bevavior of generics or how they relate to other generics without knowing what will be in their place when compiling and running the code)。 +每种编程语言都有着用于有效处理重复概念的一些工具。在 Rust 中,一种这样的工具就是 *泛型(generics)*:将一些具体类型或其他属性的替身抽象出来。对于在编译及运行代码时泛型处有着什么,咱们无需知悉就可以表达泛型的行为,或与其他泛型之间的关系(abstract stand-ins for concret types or other properties. We can express the bevavior of generics or how they relate to other generics without knowing what will be in their place when compiling and running the code)。 函数可以其取一些未知值,来在多个具体值上运行函数体中同样代码的方式,而取得某些泛型的参数,而非像是 `i32` 或 `String` 这样的具体类型。事实上,前面在第 6 章的 `Option`,第 8 章的 `Vec` 和 `HashMap`,还有第 9 章的 `Result` 中,就已经用到了泛型特性。本章中,将探讨怎样定义咱们自己的带有泛型特性的类型、函数及方法!