1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#[cfg(feature = "ok")]
fn main() {
use std::sync::mpsc;
use std::thread;
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let instance = String::from("hi");
println!("Got from tx: {}", instance);
// the variable instance begin to move
tx.send(instance).unwrap();
// the variable instance moved here
// ERROR: The variable instance borrowed here after move
//println!("val is {}", &instance);
});
let received = rx.recv().unwrap();
println!("Got from rx: {}", received);
}
#[cfg(feature = "err")]
fn main() {
use std::sync::mpsc;
use std::thread;
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let instance = String::from("hi");
println!("Got from tx: {}", instance);
// the variable instance begin to move
tx.send(&instance).unwrap();
// borrowed value does not live long enough argument
// requires that instance is borrowed for 1
// the variable instance moved here
// ERROR: The variable instance borrowed here after move
// The variable instance dropped here while still borrowed
println!("val is {}", &instance);
});
let received = rx.recv().unwrap();
println!("Got from rx: {}", received);
}
#[cfg(all(not(feature = "ok"), not(feature = "err")))]
fn main() {
use aide::hello;
hello();
}
// https://doc.rust-lang.org/stable/error-index.html#E0597