官术网_书友最值得收藏!

Sharing code among types

An unusual feature of the Rust programming language is the decision to use traits over interfaces. The latter is very common across modern object-oriented languages and unifies the API of a class (or similar) to the caller, making it possible to switch the entire implementation without the caller's knowledge. In Rust, the separation is a bit different: traits are more akin to abstract classes since they provide the API aspect as well as default implementations. struct can implement various traits, thereby offering the same behavior with other structs that implement the same traits. 

主站蜘蛛池模板: 武冈市| 固始县| 博湖县| 宽城| 城口县| 内丘县| 枣阳市| 蓝田县| 柳河县| 宜章县| 建瓯市| 新野县| 大庆市| 平塘县| 达孜县| 绍兴县| 城市| 承德县| 安义县| 平阳县| 保德县| 南汇区| 虎林市| 大城县| 诸暨市| 剑阁县| 漳浦县| 黄龙县| 运城市| 上饶县| 资阳市| 绵阳市| 静安区| 西昌市| 竹北市| 太白县| 东光县| 江城| 抚远县| 岑巩县| 东港市|