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

  • Rust Programming By Example
  • Guillaume Gomez Antoni Boucher
  • 86字
  • 2021-07-02 19:13:00

Rules

There are some rules that must be followed in order to use traits. The compiler will throw an error if they are not respected:

  • The trait must be imported in order to use its methods
  • The implementation of a trait must be in the same crate as the trait or the type

The second rule is to avoid conflicts that could otherwise happen when using multiple libraries. We can have such a conflict when two imported traits provide the same method for the same type.

主站蜘蛛池模板: 连州市| 凌云县| 新野县| 盐池县| 平谷区| 怀安县| 斗六市| 商洛市| 延边| 哈密市| 天水市| 油尖旺区| 哈密市| 宾阳县| 海安县| 新和县| 济宁市| 专栏| 沅陵县| 沙河市| 饶平县| 香河县| 都匀市| 丰镇市| 咸阳市| 苏尼特左旗| 乌拉特中旗| 昆明市| 两当县| 沛县| 郧西县| 惠来县| 荥经县| 平安县| 石阡县| 湾仔区| 迁安市| 常州市| 攀枝花市| 湟中县| 拉萨市|