A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://doc.rust-lang.org/core/task/enum.Poll.html below:

Poll in core::task - Rust

Enum Poll1.36.0 · Source
pub enum Poll<T> {
    Ready(T),
    Pending,
}
Expand description

Indicates whether a value is available or if the current task has been scheduled to receive a wakeup instead.

This is returned by Future::poll.

§1.36.0

Represents that a value is immediately ready.

§1.36.0

Represents that a value is not ready yet.

When a function returns Pending, the function must also ensure that the current task is scheduled to be awoken when progress can be made.

Source§ 1.36.0 · Source

Maps a Poll<T> to Poll<U> by applying a function to a contained value.

§Examples

Converts a Poll<String> into a Poll<usize>, consuming the original:

let poll_some_string = Poll::Ready(String::from("Hello, World!"));
let poll_some_len = poll_some_string.map(|s| s.len());

assert_eq!(poll_some_len, Poll::Ready(13));
1.36.0 (const: 1.49.0) · Source

Returns true if the poll is a Poll::Ready value.

§Examples
let x: Poll<u32> = Poll::Ready(2);
assert_eq!(x.is_ready(), true);

let x: Poll<u32> = Poll::Pending;
assert_eq!(x.is_ready(), false);
1.36.0 (const: 1.49.0) · Source

Returns true if the poll is a Pending value.

§Examples
let x: Poll<u32> = Poll::Ready(2);
assert_eq!(x.is_pending(), false);

let x: Poll<u32> = Poll::Pending;
assert_eq!(x.is_pending(), true);
Source§ 1.36.0 · Source

Maps a Poll<Result<T, E>> to Poll<Result<U, E>> by applying a function to a contained Poll::Ready(Ok) value, leaving all other variants untouched.

This function can be used to compose the results of two functions.

§Examples
let res: Poll<Result<u8, _>> = Poll::Ready("12".parse());
let squared = res.map_ok(|n| n * n);
assert_eq!(squared, Poll::Ready(Ok(144)));
1.36.0 · Source

Maps a Poll::Ready<Result<T, E>> to Poll::Ready<Result<T, F>> by applying a function to a contained Poll::Ready(Err) value, leaving all other variants untouched.

This function can be used to pass through a successful result while handling an error.

§Examples
let res: Poll<Result<u8, _>> = Poll::Ready("oops".parse());
let res = res.map_err(|_| 0_u8);
assert_eq!(res, Poll::Ready(Err(0)));
Source§ 1.51.0 · Source

Maps a Poll<Option<Result<T, E>>> to Poll<Option<Result<U, E>>> by applying a function to a contained Poll::Ready(Some(Ok)) value, leaving all other variants untouched.

This function can be used to compose the results of two functions.

§Examples
let res: Poll<Option<Result<u8, _>>> = Poll::Ready(Some("12".parse()));
let squared = res.map_ok(|n| n * n);
assert_eq!(squared, Poll::Ready(Some(Ok(144))));
1.51.0 · Source

Maps a Poll::Ready<Option<Result<T, E>>> to Poll::Ready<Option<Result<T, F>>> by applying a function to a contained Poll::Ready(Some(Err)) value, leaving all other variants untouched.

This function can be used to pass through a successful result while handling an error.

§Examples
let res: Poll<Option<Result<u8, _>>> = Poll::Ready(Some("oops".parse()));
let res = res.map_err(|_| 0_u8);
assert_eq!(res, Poll::Ready(Some(Err(0))));
1.36.0 · Source§ 1.36.0 · Source§ 1.36.0 · Source§ Source§

Moves the value into a Poll::Ready to make a Poll<T>.

§Example
assert_eq!(Poll::from(true), Poll::Ready(true));
Source§ Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277)

Constructs the type from a compatible

Residual

type.

Read more Source§ Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277)

Constructs the type from a compatible

Residual

type.

Read more 1.36.0 · Source§ 1.36.0 · Source§ 1.36.0 · Source§ Source§

Tests for self and other values to be equal, and is used by ==.

1.0.0 · Source§

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

1.36.0 · Source§ Source§

This method returns an ordering between

self

and

other

values if one exists.

Read more 1.0.0 · Source§

Tests less than (for

self

and

other

) and is used by the

<

operator.

Read more 1.0.0 · Source§

Tests less than or equal to (for

self

and

other

) and is used by the

<=

operator.

Read more 1.0.0 · Source§

Tests greater than (for

self

and

other

) and is used by the

>

operator.

Read more 1.0.0 · Source§

Tests greater than or equal to (for

self

and

other

) and is used by the

>=

operator.

Read more Source§ Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277)

The type of the value produced by ? when not short-circuiting.

Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277) Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277)

Constructs the type from its

Output

type.

Read more Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277) Source§ Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277)

The type of the value produced by ? when not short-circuiting.

Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277) Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277)

Constructs the type from its

Output

type.

Read more Source§ 🔬This is a nightly-only experimental API. (try_trait_v2 #84277) 1.36.0 · Source§ 1.36.0 · Source§ 1.36.0 · Source§

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4