Rust语言的一点概念

  1. rustup是关于toolchain和安装的工具
  2. 更新crate.io index慢,需要配置镜像网站
    1. 修改或新建 $CARGO_HOME/.cargo/confg
    2. 具体的配置参考https://doc.rust-lang.org/cargo/reference/config.html
    3. 主要是增加mirror和offline模式,如果retry失败就进入offline模式,不需要每次更新crate.io index
    1. crate 是这种装牛奶的箱子
    2. 在rust里面表示一个包,经常有二进制的输出
    3. crater是火山口
  3. cargo
    1. the goods carried by a ship, plane, or other largevehicle
    2. 必须要是被运输的东西才能够叫cargo,比如信件,所以翻译成货物是不准确的,cargo更多强调的是被类似集装箱的运输性。
    3. 和cargo比较类似的是freight,但是freight一般指的是被火车或者大卡车运输的货,类似一车皮这样的量词
    4. cargo是rust里面打包,发布,依赖管理,format管理等等的一个工具箱。通过cargo处理以后,程序就像一个ready to go的货物了,很贴切
  4. trait
    1. a particular characteristic that can produce a particulartype of behaviour:
      1. His sense of humour is one of his better traits.
      2. Arrogance is a very unattractive personality/character trait.
    2.   trait指的是一种人的特质。trait和characristics ,personality相比,chararistic指的是性格,personality指的是个性或者人格,trait我理解是更深层的特质。也可以形容物理层面的,比如高矮胖瘦
    3. 在rust里,trait是一个type对外暴露函数接口集合的名字,类似Java的interface,用trait来描述一个type是特性是合适的,比interface更加贴切。
  5. Rustaceans
    1. 因为这个是从甲壳纲动物这个单词Crustacean[[krʌ'steʃən]],去掉了首字母C
    2. Rustaceans是指对在rust社区深入活动的人群
  6. Shadowing
    1. 重复赋值 非mut的变量是允许的,这在rust里面叫shadowing,这和assignment是不同的。
    2. you can declare a new variable with the same name as a previous variable.
    3. Rustaceans say that the first variable is shadowed by the second, which means that the second variable is what the compiler will see when you use the name of the variable.
    4. In effect, the second variable overshadows the first, taking any uses of the variable name to itself until either it itself is shadowed or the scope ends.
    5. shadowing是有作用域的
  7.  
posted @ 2023-01-13 16:23  飞机云  阅读(81)  评论(0编辑  收藏  举报