mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-17 00:00:11 +02:00
task: make LocalKey::get work with Clone types (#6433)
Signed-off-by: Pierre Fenoll <[email protected]>
This commit is contained in:
@@ -264,16 +264,16 @@ impl<T: 'static> LocalKey<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy + 'static> LocalKey<T> {
|
||||
impl<T: Clone + 'static> LocalKey<T> {
|
||||
/// Returns a copy of the task-local value
|
||||
/// if the task-local value implements `Copy`.
|
||||
/// if the task-local value implements `Clone`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// This function will panic if the task local doesn't have a value set.
|
||||
#[track_caller]
|
||||
pub fn get(&'static self) -> T {
|
||||
self.with(|v| *v)
|
||||
self.with(|v| v.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user