Skip to content

Instantly share code, notes, and snippets.

@se1983
se1983 / playground.rs
Last active April 19, 2020 06:39 — forked from rust-play/playground.rs
Channels between two threads
use std::thread;
use std::sync::mpsc;
fn main() {
let (tx, rx) = mpsc::channel();
let h1 = thread::spawn(move || {
let val = String::from("hi");
tx.send(val).unwrap();
});
@se1983
se1983 / playground.rs
Created March 19, 2020 12:28 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::thread;
use std::time::Duration;
use std::collections::HashMap;
struct Cacher<T> where T: Fn(u32) -> u32{
calculation: T,
values: HashMap<u32, u32>
}
impl<T> Cacher<T> where T: Fn(u32) -> u32 {