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

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. 

主站蜘蛛池模板: 石泉县| 隆回县| 醴陵市| 尤溪县| 西贡区| 全椒县| 漳州市| 格尔木市| 宣恩县| 广河县| 青浦区| 大石桥市| 襄城县| 郸城县| 汉川市| 乐安县| 项城市| 津市市| 阿巴嘎旗| 潜山县| 大港区| 泸州市| 蒙城县| 略阳县| 县级市| 南宁市| 南丰县| 顺义区| 九龙坡区| 翁牛特旗| 峨眉山市| 汶川县| 邳州市| 南木林县| 海阳市| 和硕县| 慈利县| 沧州市| 辽宁省| 罗定市| 华宁县|