Skip to content

Commit

Permalink
task: fix wording with 'unsend' (#5452)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdejager authored Feb 14, 2023
1 parent d1da6c2 commit 28d6f4d
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tokio/src/task/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ cfg_rt! {
/// async fn main() {
/// // `Rc` does not implement `Send`, and thus may not be sent between
/// // threads safely.
/// let unsend_data = Rc::new("my unsend data...");
/// let nonsend_data = Rc::new("my nonsend data...");
///
/// let unsend_data = unsend_data.clone();
/// // Because the `async` block here moves `unsend_data`, the future is `!Send`.
/// let nonsend_data = nonsend_data.clone();
/// // Because the `async` block here moves `nonsend_data`, the future is `!Send`.
/// // Since `tokio::spawn` requires the spawned future to implement `Send`, this
/// // will not compile.
/// tokio::spawn(async move {
/// println!("{}", unsend_data);
/// println!("{}", nonsend_data);
/// // ...
/// }).await.unwrap();
/// }
Expand All @@ -60,18 +60,18 @@ cfg_rt! {
///
/// #[tokio::main]
/// async fn main() {
/// let unsend_data = Rc::new("my unsend data...");
/// let nonsend_data = Rc::new("my nonsend data...");
///
/// // Construct a local task set that can run `!Send` futures.
/// let local = task::LocalSet::new();
///
/// // Run the local task set.
/// local.run_until(async move {
/// let unsend_data = unsend_data.clone();
/// let nonsend_data = nonsend_data.clone();
/// // `spawn_local` ensures that the future is spawned on the local
/// // task set.
/// task::spawn_local(async move {
/// println!("{}", unsend_data);
/// println!("{}", nonsend_data);
/// // ...
/// }).await.unwrap();
/// }).await;
Expand All @@ -94,18 +94,18 @@ cfg_rt! {
///
/// #[tokio::main]
/// async fn main() {
/// let unsend_data = Rc::new("world");
/// let nonsend_data = Rc::new("world");
/// let local = task::LocalSet::new();
///
/// let unsend_data2 = unsend_data.clone();
/// let nonsend_data2 = nonsend_data.clone();
/// local.spawn_local(async move {
/// // ...
/// println!("hello {}", unsend_data2)
/// println!("hello {}", nonsend_data2)
/// });
///
/// local.spawn_local(async move {
/// time::sleep(time::Duration::from_millis(100)).await;
/// println!("goodbye {}", unsend_data)
/// println!("goodbye {}", nonsend_data)
/// });
///
/// // ...
Expand Down Expand Up @@ -309,15 +309,15 @@ cfg_rt! {
///
/// #[tokio::main]
/// async fn main() {
/// let unsend_data = Rc::new("my unsend data...");
/// let nonsend_data = Rc::new("my nonsend data...");
///
/// let local = task::LocalSet::new();
///
/// // Run the local task set.
/// local.run_until(async move {
/// let unsend_data = unsend_data.clone();
/// let nonsend_data = nonsend_data.clone();
/// task::spawn_local(async move {
/// println!("{}", unsend_data);
/// println!("{}", nonsend_data);
/// // ...
/// }).await.unwrap();
/// }).await;
Expand Down

0 comments on commit 28d6f4d

Please sign in to comment.