-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Open
Description
Listing 17-11
looks like this currently:
let tx_fut = async {
let vals = vec![
String::from("hi"),
String::from("from"),
String::from("the"),
String::from("future"),
];
for val in vals {
tx.send(val).unwrap();
trpl::sleep(Duration::from_millis(500)).await;
}
};
let rx_fut = async {
while let Some(value) = rx.recv().await {
println!("received '{value}'");
}
};
trpl::join(tx_fut, rx_fut).await;
Confusion
Listing 17-11
lacks let (tx, mut rx) = trpl::channel();
in the beginning of the listing
Other Listings in the 17.2.
chapter that relate to this code, they all have this line.
Suggestion
Add this line into the listing:
let (tx, mut rx) = trpl::channel();
let tx_fut = async {
let vals = vec![
String::from("hi"),
String::from("from"),
String::from("the"),
String::from("future"),
];
for val in vals {
tx.send(val).unwrap();
trpl::sleep(Duration::from_millis(500)).await;
}
};
let rx_fut = async {
while let Some(value) = rx.recv().await {
println!("received '{value}'");
}
};
trpl::join(tx_fut, rx_fut).await;
Metadata
Metadata
Assignees
Labels
No labels