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

Enhance Documentation: Alternatives to select! Macro #7110

Merged
merged 15 commits into from
Feb 15, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: fix warnings in select! alternatives examples
Ddystopia committed Jan 28, 2025

Verified

This commit was signed with the committer’s verified signature.
Ddystopia Oleksandr Babak
commit 4e3ff176f5aa42ecf90f9f5c8c8824e9766640e7
20 changes: 9 additions & 11 deletions tokio/src/macros/select.rs
Original file line number Diff line number Diff line change
@@ -418,9 +418,7 @@ macro_rules! doc {
///
/// ### Example with `select!`
///
/// ```ignore
/// use std::pin::pin;
///
/// ```
/// struct File;
/// struct Channel;
/// struct Socket;
@@ -431,7 +429,7 @@ macro_rules! doc {
/// }
/// }
///
/// async fn read_send(file: &mut File, channel: &mut Channel) {
/// async fn read_send(_file: &mut File, _channel: &mut Channel) {
/// // do work that is not cancel safe
/// }
///
@@ -445,7 +443,7 @@ macro_rules! doc {
/// loop {
/// tokio::select! {
/// _ = read_send(&mut file, &mut channel) => { /* ... */ },
/// data = socket.read_packet() => { /* ... */ }
/// _data = socket.read_packet() => { /* ... */ }
/// }
/// }
/// }
@@ -457,7 +455,7 @@ macro_rules! doc {
/// eliminating the need to manage tasks manually and reducing the risk of
/// unintended behavior like data loss.
///
/// ```ignore
/// ```
/// use std::pin::pin;
///
/// use futures::stream::unfold;
@@ -473,7 +471,7 @@ macro_rules! doc {
/// }
/// }
///
/// async fn read_send(file: &mut File, channel: &mut Channel) {
/// async fn read_send(_file: &mut File, _channel: &mut Channel) {
/// // do work that is not cancel safe
/// }
///
@@ -485,9 +483,9 @@ macro_rules! doc {
/// #[tokio::main]
/// async fn main() {
/// // open our IO types
/// let mut file = File;
/// let mut channel = Channel;
/// let mut socket = Socket;
/// let file = File;
/// let channel = Channel;
/// let socket = Socket;
///
/// let a = unfold((file, channel), |(mut file, mut channel)| async {
/// read_send(&mut file, &mut channel).await;
@@ -502,7 +500,7 @@ macro_rules! doc {
/// while let Some(msg) = s.next().await {
/// match msg {
/// Message::None => continue,
/// Message::Data(data) => { /* ... */ }
/// Message::Data(_data) => { /* ... */ }
/// }
/// }
/// }