Skip to content

Commit 9d9543c

Browse files
committed
refactor: Remove needless main fn
1 parent 30b5ca5 commit 9d9543c

File tree

17 files changed

+53
-55
lines changed

17 files changed

+53
-55
lines changed

src/future/pending.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::task::{Context, Poll};
99
/// # Examples
1010
///
1111
/// ```
12-
/// # fn main() { async_std::task::block_on(async {
12+
/// # async_std::task::block_on(async {
1313
/// #
1414
/// use std::time::Duration;
1515
///
@@ -22,7 +22,7 @@ use crate::task::{Context, Poll};
2222
/// let res: io::Result<()> = io::timeout(dur, fut).await;
2323
/// assert!(res.is_err());
2424
/// #
25-
/// # }) }
25+
/// # })
2626
/// ```
2727
pub async fn pending<T>() -> T {
2828
let fut = Pending {

src/future/poll_fn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::task::{Context, Poll};
1010
/// # Examples
1111
///
1212
/// ```
13-
/// # fn main() { async_std::task::block_on(async {
13+
/// # async_std::task::block_on(async {
1414
/// #
1515
/// use async_std::future;
1616
/// use async_std::task::{Context, Poll};
@@ -21,7 +21,7 @@ use crate::task::{Context, Poll};
2121
///
2222
/// assert_eq!(future::poll_fn(poll_greeting).await, "hello world");
2323
/// #
24-
/// # }) }
24+
/// # })
2525
/// ```
2626
pub async fn poll_fn<F, T>(f: F) -> T
2727
where

src/future/ready.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
/// # Examples
88
///
99
/// ```
10-
/// # fn main() { async_std::task::block_on(async {
10+
/// # async_std::task::block_on(async {
1111
/// #
1212
/// use async_std::future;
1313
///
1414
/// assert_eq!(future::ready(10).await, 10);
1515
/// #
16-
/// # }) }
16+
/// # })
1717
/// ```
1818
pub async fn ready<T>(val: T) -> T {
1919
val

src/stream/empty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::task::{Context, Poll};
99
/// # Examples
1010
///
1111
/// ```
12-
/// # fn main() { async_std::task::block_on(async {
12+
/// # async_std::task::block_on(async {
1313
/// #
1414
/// use async_std::prelude::*;
1515
/// use async_std::stream;
@@ -18,7 +18,7 @@ use crate::task::{Context, Poll};
1818
///
1919
/// assert_eq!(s.next().await, None);
2020
/// #
21-
/// # }) }
21+
/// # })
2222
/// ```
2323
pub fn empty<T>() -> Empty<T> {
2424
Empty {

src/stream/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! # Examples
88
//!
99
//! ```
10-
//! # fn main() { async_std::task::block_on(async {
10+
//! # async_std::task::block_on(async {
1111
//! #
1212
//! use async_std::prelude::*;
1313
//! use async_std::stream;
@@ -18,7 +18,7 @@
1818
//! assert_eq!(v, 9);
1919
//! }
2020
//! #
21-
//! # }) }
21+
//! # })
2222
//! ```
2323
2424
use cfg_if::cfg_if;

src/stream/once.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::task::{Context, Poll};
88
/// # Examples
99
///
1010
/// ```
11-
/// # fn main() { async_std::task::block_on(async {
11+
/// # async_std::task::block_on(async {
1212
/// #
1313
/// use async_std::prelude::*;
1414
/// use async_std::stream;
@@ -18,7 +18,7 @@ use crate::task::{Context, Poll};
1818
/// assert_eq!(s.next().await, Some(7));
1919
/// assert_eq!(s.next().await, None);
2020
/// #
21-
/// # }) }
21+
/// # })
2222
/// ```
2323
pub fn once<T>(t: T) -> Once<T> {
2424
Once { value: Some(t) }

src/stream/repeat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::task::{Context, Poll};
88
/// # Examples
99
///
1010
/// ```
11-
/// # fn main() { async_std::task::block_on(async {
11+
/// # async_std::task::block_on(async {
1212
/// #
1313
/// use async_std::prelude::*;
1414
/// use async_std::stream;
@@ -18,7 +18,7 @@ use crate::task::{Context, Poll};
1818
/// assert_eq!(s.next().await, Some(7));
1919
/// assert_eq!(s.next().await, Some(7));
2020
/// #
21-
/// # }) }
21+
/// # })
2222
/// ```
2323
pub fn repeat<T>(item: T) -> Repeat<T>
2424
where

src/stream/stream/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! # Examples
88
//!
99
//! ```
10-
//! # fn main() { async_std::task::block_on(async {
10+
//! # async_std::task::block_on(async {
1111
//! #
1212
//! use async_std::prelude::*;
1313
//! use async_std::stream;
@@ -18,7 +18,7 @@
1818
//! assert_eq!(v, 9);
1919
//! }
2020
//! #
21-
//! # }) }
21+
//! # })
2222
//! ```
2323
2424
mod all;

src/sync/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! Spawn a task that updates an integer protected by a mutex:
1010
//!
1111
//! ```
12-
//! # fn main() { async_std::task::block_on(async {
12+
//! # async_std::task::block_on(async {
1313
//! #
1414
//! use std::sync::Arc;
1515
//!
@@ -26,7 +26,7 @@
2626
//!
2727
//! assert_eq!(*m1.lock().await, 1);
2828
//! #
29-
//! # }) }
29+
//! # })
3030
//! ```
3131
3232
#[doc(inline)]

src/sync/mutex.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const BLOCKED: usize = 1 << 1;
2424
/// # Examples
2525
///
2626
/// ```
27-
/// # fn main() { async_std::task::block_on(async {
27+
/// # async_std::task::block_on(async {
2828
/// #
2929
/// use std::sync::Arc;
3030
///
@@ -46,7 +46,7 @@ const BLOCKED: usize = 1 << 1;
4646
/// }
4747
/// assert_eq!(*m.lock().await, 10);
4848
/// #
49-
/// # }) }
49+
/// # })
5050
/// ```
5151
pub struct Mutex<T> {
5252
state: AtomicUsize,
@@ -82,7 +82,7 @@ impl<T> Mutex<T> {
8282
/// # Examples
8383
///
8484
/// ```
85-
/// # fn main() { async_std::task::block_on(async {
85+
/// # async_std::task::block_on(async {
8686
/// #
8787
/// use std::sync::Arc;
8888
///
@@ -99,7 +99,7 @@ impl<T> Mutex<T> {
9999
///
100100
/// assert_eq!(*m2.lock().await, 20);
101101
/// #
102-
/// # }) }
102+
/// # })
103103
/// ```
104104
pub async fn lock(&self) -> MutexGuard<'_, T> {
105105
pub struct LockFuture<'a, T> {
@@ -196,7 +196,7 @@ impl<T> Mutex<T> {
196196
/// # Examples
197197
///
198198
/// ```
199-
/// # fn main() { async_std::task::block_on(async {
199+
/// # async_std::task::block_on(async {
200200
/// #
201201
/// use std::sync::Arc;
202202
///
@@ -217,7 +217,7 @@ impl<T> Mutex<T> {
217217
///
218218
/// assert_eq!(*m2.lock().await, 20);
219219
/// #
220-
/// # }) }
220+
/// # })
221221
/// ```
222222
pub fn try_lock(&self) -> Option<MutexGuard<'_, T>> {
223223
if self.state.fetch_or(LOCK, Ordering::Acquire) & LOCK == 0 {
@@ -249,15 +249,15 @@ impl<T> Mutex<T> {
249249
/// # Examples
250250
///
251251
/// ```
252-
/// # fn main() { async_std::task::block_on(async {
252+
/// # async_std::task::block_on(async {
253253
/// #
254254
/// use async_std::sync::Mutex;
255255
///
256256
/// let mut mutex = Mutex::new(0);
257257
/// *mutex.get_mut() = 10;
258258
/// assert_eq!(*mutex.lock().await, 10);
259259
/// #
260-
/// # }) }
260+
/// # })
261261
/// ```
262262
pub fn get_mut(&mut self) -> &mut T {
263263
unsafe { &mut *self.value.get() }

0 commit comments

Comments
 (0)