We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
set_current
1 parent e2cf2cb commit e7b5730Copy full SHA for e7b5730
library/std/src/thread/mod.rs
@@ -684,9 +684,12 @@ thread_local! {
684
685
/// Sets the thread handle for the current thread.
686
///
687
-/// Panics if the handle has been set already or when called from a TLS destructor.
+/// Aborts if the handle has been set already to reduce code size.
688
pub(crate) fn set_current(thread: Thread) {
689
- CURRENT.with(|current| current.set(thread).unwrap());
+ CURRENT.with(|current| match current.set(thread) {
690
+ Ok(()) => {}
691
+ Err(_) => rtabort!("should only be set once"),
692
+ });
693
}
694
695
/// Gets a handle to the thread that invokes it.
0 commit comments