Skip to content

Commit 1d999e0

Browse files
authored
Merge pull request #4 from wanglong001/master
[fix] thread/src/threads.rs check none
2 parents 461cbee + f080009 commit 1d999e0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

thread/src/threads.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub fn start_one_thread_with_move() {
176176

177177
handle.join().unwrap();
178178

179-
let handle = thread::spawn(move|| {
179+
let handle = thread::spawn(move || {
180180
println!("Hello from a thread with move again, x={}!", x);
181181
});
182182
handle.join().unwrap();
@@ -185,7 +185,6 @@ pub fn start_one_thread_with_move() {
185185
println!("Hello from a thread without move");
186186
});
187187
handle.join().unwrap();
188-
189188
}
190189

191190
// pub fn start_one_thread_with_move2() {
@@ -360,7 +359,6 @@ pub fn rayon_scope() {
360359
assert_eq!(x, a.len());
361360
}
362361

363-
364362
// pub fn wrong_send() {
365363
// let counter = Rc::new(42);
366364

@@ -398,7 +396,9 @@ pub fn print_thread_amount() {
398396

399397
let handle = thread::spawn(move || {
400398
thread::sleep(Duration::from_millis(1000));
401-
println!("thread amount: {}", amount.unwrap());
399+
if !amount.is_none() {
400+
println!("thread amount: {}", amount.unwrap());
401+
}
402402
});
403403

404404
handles.push(handle);
@@ -490,7 +490,9 @@ pub fn info() {
490490
}
491491

492492
let count = thread_amount::thread_amount();
493-
println!("thread_amount: {}", count.unwrap());
493+
if !count.is_none() {
494+
println!("thread_amount: {}", count.unwrap());
495+
}
494496

495497
let count = num_cpus::get();
496498
println!("num_cpus: {}", count);

0 commit comments

Comments
 (0)