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

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. 

主站蜘蛛池模板: 保德县| 贺兰县| 固镇县| 绿春县| 五华县| 耒阳市| 外汇| 襄樊市| 沙雅县| 东乡县| 璧山县| 海兴县| 南宁市| 甘南县| 卫辉市| 孟连| 秦皇岛市| 宣汉县| 辽阳市| 错那县| 玛曲县| 陵川县| 兴城市| 陆川县| 凤庆县| 华坪县| 岳普湖县| 高阳县| 马鞍山市| 荣成市| 肇东市| 浦北县| 浦县| 安岳县| 阳信县| 山西省| 三原县| 南雄市| 广德县| 旅游| 安岳县|