wiki/content/20201120111157-ready.md

40 lines
673 B
Markdown
Raw Normal View History

2024-05-06 20:40:05 +00:00
---
2024-10-29 18:27:12 +00:00
date: 2020-11-20
2024-05-06 20:40:05 +00:00
id: 23599316-9c90-48cf-b77d-63b5ee1a8496
title: ready
---
# Description
readcy[^1] creates a future that is immediately ready with a value.
Futures created through this function are functionally similar to those
created through `async {}`. The main difference is that futures created
through this function are named and implement `Unpin`.
# Declaration
``` rust
pub fn ready<T>() -> Ready<T>
```
# Notable traits
``` rust
impl<T> Future for Ready<T>
type Output = T;
```
# Examples
``` rust
use core::future;
let a = future::ready(1);
assert_eq!(a.await, 1);
```
# Footnotes
[^1]: <https://doc.rust-lang.org/std/future/fn.pending.html>