Skip to content

Commit 3e19f26

Browse files
committed
Add future::ready implementation
1 parent 61e339a commit 3e19f26

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/future.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
use futures::future::Future;
22

3+
pub async fn ready<T>(value: T) -> T {
4+
value
5+
}
6+
37
pub async fn map<Fut, U, F>(future: Fut, f: F) -> U
48
where F: FnOnce(Fut::Output) -> U,
59
Fut: Future,
@@ -87,6 +91,14 @@ mod tests {
8791
use futures::{future, executor};
8892
use crate::future::*;
8993

94+
#[test]
95+
fn test_ready() {
96+
executor::block_on(async {
97+
let future = ready(1);
98+
assert_eq!(await!(future), 1);
99+
});
100+
}
101+
90102
#[test]
91103
fn test_map() {
92104
executor::block_on(async {

0 commit comments

Comments
 (0)