Skip to content

Commit

Permalink
style: Rename spawn<T> to spawn<F>
Browse files Browse the repository at this point in the history
tokio::task::spawn_local is generic over F but tokio::task::spawn is generic over T. I think they should match, and F is more descriptive (F for Future).
  • Loading branch information
adamchalmers committed Sep 9, 2023
1 parent a6be73e commit 7225c48
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tokio/src/task/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ cfg_rt! {
/// error[E0391]: cycle detected when processing `main`
/// ```
#[track_caller]
pub fn spawn<T>(future: T) -> JoinHandle<T::Output>
pub fn spawn<F>(future: F) -> JoinHandle<F::Output>
where
T: Future + Send + 'static,
T::Output: Send + 'static,
F: Future + Send + 'static,
F::Output: Send + 'static,
{
// preventing stack overflows on debug mode, by quickly sending the
// task to the heap.
if cfg!(debug_assertions) && std::mem::size_of::<T>() > 2048 {
if cfg!(debug_assertions) && std::mem::size_of::<F>() > 2048 {
spawn_inner(Box::pin(future), None)
} else {
spawn_inner(future, None)
Expand Down

0 comments on commit 7225c48

Please sign in to comment.