diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/syn/src/thread.rs | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/syn/src/thread.rs')
-rw-r--r-- | vendor/syn/src/thread.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/vendor/syn/src/thread.rs b/vendor/syn/src/thread.rs index 9e5d8ad85..63fdea834 100644 --- a/vendor/syn/src/thread.rs +++ b/vendor/syn/src/thread.rs @@ -4,7 +4,7 @@ use std::thread::{self, ThreadId}; /// ThreadBound is a Sync-maker and Send-maker that allows accessing a value /// of type T only from the original thread on which the ThreadBound was /// constructed. -pub struct ThreadBound<T> { +pub(crate) struct ThreadBound<T> { value: T, thread_id: ThreadId, } @@ -15,14 +15,14 @@ unsafe impl<T> Sync for ThreadBound<T> {} unsafe impl<T: Copy> Send for ThreadBound<T> {} impl<T> ThreadBound<T> { - pub fn new(value: T) -> Self { + pub(crate) fn new(value: T) -> Self { ThreadBound { value, thread_id: thread::current().id(), } } - pub fn get(&self) -> Option<&T> { + pub(crate) fn get(&self) -> Option<&T> { if thread::current().id() == self.thread_id { Some(&self.value) } else { @@ -39,3 +39,12 @@ impl<T: Debug> Debug for ThreadBound<T> { } } } + +impl<T: Clone> Clone for ThreadBound<T> { + fn clone(&self) -> Self { + ThreadBound { + value: self.value.clone(), + thread_id: self.thread_id, + } + } +} |