string_thread/
string_thread.rs

1#[cfg(feature = "ok")]
2fn main() {
3    use std::sync::mpsc;
4    use std::thread;
5
6    let (tx, rx) = mpsc::channel();
7
8    thread::spawn(move || {
9        let instance = String::from("hi");
10        println!("Got from tx: {}", instance);
11
12        // the variable `instance` begin to move
13        tx.send(instance).unwrap();
14        // the variable `instance` moved here
15
16        // ERROR: The variable `instance` borrowed here after move
17        //println!("val is {}", instance);
18    });
19
20    let received = rx.recv().unwrap();
21    println!("Got from rx: {}", received);
22}
23
24#[cfg(feature = "err")]
25fn main() {
26    use std::sync::mpsc;
27    use std::thread;
28
29    let (tx, rx) = mpsc::channel();
30
31    thread::spawn(move || {
32        let instance = String::from("hi");
33        println!("Got from tx: {}", instance);
34
35        // the variable `instance` begin to move
36        tx.send(instance).unwrap();
37        // the variable `instance` moved here
38
39        // ERROR: The variable `instance` borrowed here after move
40        println!("val is {}", instance);
41    });
42
43    let received = rx.recv().unwrap();
44    println!("Got from rx: {}", received);
45}
46
47#[cfg(all(not(feature = "ok"), not(feature = "err")))]
48fn main() {
49    use aide::hello;
50    hello();
51}