2020年12月28日

摘要: https://blog.csdn.net/guiqulaxi920/article/details/78823541 fn main() { // Basic Range (exclusive on the right) for i in 1..11 { print!("{} ", i); } p 阅读全文
posted @ 2020-12-28 17:39 tycoon3 阅读(147) 评论(0) 推荐(0)
摘要: https://github.com/rustomax/rust-iterators 1、迭代器是什么? 迭代器(iterator)负责遍历序列中的每一项和决定序列何时结束的逻辑,迭代器是 惰性的(lazy)。迭代器模式允许你对一个项的序列进行某些处理。 let v = vec![1, 2, 3]; 阅读全文
posted @ 2020-12-28 17:25 tycoon3 阅读(581) 评论(0) 推荐(0)
摘要: use futures::{ self, executor}; use std::thread; use std::time; async fn song() { loop { println!("song!"); thread::sleep(time::Duration::from_secs(5) 阅读全文
posted @ 2020-12-28 15:45 tycoon3 阅读(232) 评论(0) 推荐(0)
摘要: use std::sync::Arc; let foo = Arc::new(vec![1.0, 2.0, 3.0]); // The two syntaxes below are equivalent. let a = foo.clone(); let b = Arc::clone(&foo); 阅读全文
posted @ 2020-12-28 14:58 tycoon3 阅读(157) 评论(0) 推荐(0)
摘要: use std::thread; use std::time; use std::sync::mpsc; fn main() { let (tx, rx) : (mpsc::Sender<i32>, mpsc::Receiver<i32>) = mpsc::channel(); //drop(rx) 阅读全文
posted @ 2020-12-28 14:30 tycoon3 阅读(189) 评论(0) 推荐(0)
摘要: fn main() { let s1 = String::from("hello"); let s2 = s1; println!("s1 : {}", s1); let s3 = s2.clone(); println!("s2 : {}", s2); println!("s3 : {}", s3 阅读全文
posted @ 2020-12-28 11:35 tycoon3 阅读(341) 评论(0) 推荐(0)
摘要: use std::sync::Mutex; fn main() { let m = Mutex::new(5); //Mutex<i32>, 智能指针 { let mut num = m.lock().unwrap(); //等待,阻塞线程, //返回MutexGuard, 智能指针,实施deref 阅读全文
posted @ 2020-12-28 11:10 tycoon3 阅读(897) 评论(0) 推荐(1)
摘要: The Atomic Reference Counter (Arc) type is a smart pointer that lets you share immutable data across threads in a thread-safe way. I couldn’t find any 阅读全文
posted @ 2020-12-28 10:41 tycoon3 阅读(98) 评论(0) 推荐(0)
摘要: Blog series Part 1: Introduction & Allocators Part 2: Unq, an allocator-aware Box Part 3: Containers Part 4: Generating Vulkan bindings Welcome to Han 阅读全文
posted @ 2020-12-28 10:26 tycoon3 阅读(103) 评论(0) 推荐(0)
摘要: use std::ops::Deref; struct MyBox<T>(T); impl<T> MyBox<T> { fn new(x: T) -> MyBox<T> { MyBox(x) } } //impl<T> Deref for MyBox<T> { // type Target = T; 阅读全文
posted @ 2020-12-28 09:52 tycoon3 阅读(435) 评论(0) 推荐(0)
摘要: https://kaisery.github.io/trpl-zh-cn/ch04-02-references-and-borrowing.html 示例 4-5 中的元组代码有这样一个问题:我们必须将 String 返回给调用函数,以便在调用 calculate_length 后仍能使用 Stri 阅读全文
posted @ 2020-12-28 09:28 tycoon3 阅读(382) 评论(0) 推荐(0)

导航