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

fix: fix wording with 'unsend' #5452

Merged
merged 3 commits into from
Feb 14, 2023
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
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