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

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. 

主站蜘蛛池模板: 科尔| 台州市| 杭锦旗| 伽师县| 康平县| 广宗县| 襄城县| 广州市| 商丘市| 丰顺县| 柳州市| 高密市| 泗洪县| 涟源市| 九江市| 蛟河市| 托克逊县| 平江县| 汉中市| 岱山县| 江门市| 富川| 瓮安县| 镇坪县| 容城县| 鞍山市| 林州市| 泸溪县| 绥阳县| 卓尼县| 揭东县| 许昌县| 故城县| 黄冈市| 汶川县| 瓦房店市| 弥勒县| 五原县| 疏勒县| 三门县| 孟州市|