Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: impl Clone for task_local where T: Clone #6433

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: add clone_inner to task_local
Signed-off-by: Pierre Fenoll <[email protected]>
  • Loading branch information
fenollp committed Apr 10, 2024
commit e8a182d652080538593d4136a73572249cc54bc5
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
Loading