mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
task: make LocalKey::get
work with Clone types (#6433)
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
This commit is contained in:
parent
be9328da75
commit
ccee1d4493
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user