X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibstd%2Fsys_common%2Fthread_info.rs;h=f09d16c33e6d6401470b61814af5e2ea39ff27b8;hb=4436c9d35498e7ae3da261f6141d6d73b915e1e8;hp=b3c21ec508a9eda1cb79ce8d53b9daedd33ca8c9;hpb=d4ef74b2daab3119e34e2dbed6bb2ab40b49cae9;p=rust.git diff --git a/src/libstd/sys_common/thread_info.rs b/src/libstd/sys_common/thread_info.rs index b3c21ec508a..f09d16c33e6 100644 --- a/src/libstd/sys_common/thread_info.rs +++ b/src/libstd/sys_common/thread_info.rs @@ -12,16 +12,19 @@ struct ThreadInfo { thread_local! { static THREAD_INFO: RefCell> = RefCell::new(None) } impl ThreadInfo { - fn with(f: F) -> Option where F: FnOnce(&mut ThreadInfo) -> R { - THREAD_INFO.try_with(move |c| { - if c.borrow().is_none() { - *c.borrow_mut() = Some(ThreadInfo { - stack_guard: None, - thread: Thread::new(None), - }) - } - f(c.borrow_mut().as_mut().unwrap()) - }).ok() + fn with(f: F) -> Option + where + F: FnOnce(&mut ThreadInfo) -> R, + { + THREAD_INFO + .try_with(move |c| { + if c.borrow().is_none() { + *c.borrow_mut() = + Some(ThreadInfo { stack_guard: None, thread: Thread::new(None) }) + } + f(c.borrow_mut().as_mut().unwrap()) + }) + .ok() } } @@ -35,10 +38,7 @@ pub fn stack_guard() -> Option { pub fn set(stack_guard: Option, thread: Thread) { THREAD_INFO.with(|c| assert!(c.borrow().is_none())); - THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo{ - stack_guard, - thread, - })); + THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo { stack_guard, thread })); } pub fn reset_guard(stack_guard: Option) {