摘要:
Difference betwen require and import require can be called conditionally, while the import statement cannot import statements are hoisted, but require 阅读全文
摘要:
Generator can run with for .. of and ..., which will only emit yield values For example: function* count() { yield 1; yield 2; return 3; } for (const 阅读全文
摘要:
Create a new User instance would create a new login function in memory each time? class User { constructor(username) { this.username = username; } log 阅读全文
摘要:
use std::sync::mpsc; use std::thread; use std::time::Duration; fn main() { let (tx, rx) = mpsc::channel(); thread::spawn(move || { let vals = vec![ St 阅读全文
摘要:
A channel has two halves: a transmitter and a receiver. The transmitter half is the upstream location where you put rubber ducks into the river, and t 阅读全文
摘要:
Arc<T> is a type like Rc<T> that is safe to use in concurrent situations. The a stands for atomic, meaning it’s an atomically reference counted type. 阅读全文
摘要:
We ofter use movewith closures passed to thread::spawnbecase the closure will then take ownership of the values it uses from the environment, thus tra 阅读全文
摘要:
Code from previous blog: use std::thread; use std::time::Duration; fn main() { thread::spawn(|| { for i in 1..10 { println!("hi number {} from the spa 阅读全文
摘要:
We use spawnto create a new thread: use std::thread; use std::time::Duration; fn main() { thread::spawn(|| { for i in 1..10 { println!("hi number {} f 阅读全文
摘要:
https://doc.rust-lang.org/std/keyword.ref.html struct Point { x: i32, y: i32, } fn main() { let y: Option<Point> = Some(Point { x: 100, y: 200 }); mat 阅读全文