Skip to content

Commit

Permalink
task: make LocalKey::get work with Clone types (#6433)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <[email protected]>
  • Loading branch information
fenollp committed Apr 10, 2024
1 parent be9328d commit ccee1d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tokio/src/task/task_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down

0 comments on commit ccee1d4

Please sign in to comment.