Rust

concurrent-programming: programs can run in independent with each other. parallel programming: program can run at same time. as a low-level language, rust need less abstraction and more control. use thread process vs thread programs: Race conditions: data-race. resource-race. DeakLock difficult concurrent bug. os-thread vs green-thread: 1:1 vs M:N /// thread examples /// when the main-thread exit, the fork-thread will exit too. /// just like python thread.deamon flag. use std::thread; use std::time::Duration; fn main() { thread::spawn(|| { for i in 1.
Nov 4, 2020
4 min read
rust can bind data with methods rust can use pub/private to abstract inner implement. rust not support exntends. you should consider use combination more. extend has two more usage-point. reuse pub method from parent-class or ability to rewrite it on willing. Rust use Trait to do this. polymorphism. Parent-Ref can ref any-SubType-instances, and method-call is eval at runtime.in Rust, you may use Generics-Type and Trait-Bounds todo this. \`bounded parametric polymorphism\`. TODOTrait-object used for instances with different types Generic and Trait-Bound can only replace one type.
Nov 4, 2020
3 min read
unsafe-rust advance-trait trait-ref-type 与trait相关的关联类型 default type param 默认参数类型 fully qualified syntax 完全限定语法 supertraits 超父类 newtype模式 advance-type more about new-type pattern type alias 类型别名 never type dymatic-size type 动态大小类型 advance function and closure function point 函数指针 return closure 返回闭包 macro 宏 unsafe-rust the-addional-super power of unsafe 解引用裸指针 调用不安全的函数或方法 访问或修改可变静态变量 实现不安全的trait 访问union字段 the owner-check is still on unref-raw-point ignore owner-rule, allow mut and immute ref.
Nov 8, 2020
5 min read