Skip to content

Commit e63086a

Browse files
committed
Remove usage of async_closure
1 parent 36c15fd commit e63086a

File tree

14 files changed

+44
-44
lines changed

14 files changed

+44
-44
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Ecosystem WG, and **not ready for production use yet**.
6464
6565
fn main() -> Result<(), std::io::Error> {
6666
let mut app = tide::App::new();
67-
app.at("/").get(async move |_| "Hello, world!");
67+
app.at("/").get(|_| async move { "Hello, world!" });
6868
Ok(app.run("127.0.0.1:8000")?)
6969
}
7070
```

examples/cors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(async_await, async_closure)]
1+
#![feature(async_await)]
22

33
use http::header::HeaderValue;
44
use tide::middleware::CorsMiddleware;
@@ -12,7 +12,7 @@ fn main() {
1212
.allow_methods(HeaderValue::from_static("GET, POST, OPTIONS")),
1313
);
1414

15-
app.at("/").get(async move |_| "Hello, world!");
15+
app.at("/").get(|_| async move { "Hello, world!" });
1616

1717
app.run("127.0.0.1:8000").unwrap();
1818
}

examples/default_headers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(async_await, async_closure)]
1+
#![feature(async_await)]
22

33
use tide::middleware::DefaultHeaders;
44

@@ -11,7 +11,7 @@ fn main() {
1111
.header("X-Server", "Tide"),
1212
);
1313

14-
app.at("/").get(async move |_| "Hello, world!");
14+
app.at("/").get(|_| async move { "Hello, world!" });
1515

1616
app.run("127.0.0.1:8000").unwrap();
1717
}

examples/hello.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#![feature(async_await, async_closure)]
1+
#![feature(async_await)]
22
fn main() {
33
let mut app = tide::App::new();
4-
app.at("/").get(async move |_| "Hello, world!");
4+
app.at("/").get(|_| async move { "Hello, world!" });
55
app.run("127.0.0.1:8000").unwrap();
66
}

examples/hello_envlog.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#![feature(async_await, async_closure)]
1+
#![feature(async_await)]
22
fn main() {
33
env_logger::from_env(env_logger::Env::default().default_filter_or("info")).init();
44
let mut app = tide::App::new();
55
app.middleware(tide::middleware::RequestLogger::new());
6-
app.at("/").get(async move |_| "Hello, world!");
6+
app.at("/").get(|_| async move { "Hello, world!" });
77
app.run("127.0.0.1:8000").unwrap();
88
}

examples/hello_logrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(async_await, async_closure)]
1+
#![feature(async_await)]
22
fn main() {
33
use log::LevelFilter;
44
use log4rs::append::console::ConsoleAppender;
@@ -13,6 +13,6 @@ fn main() {
1313

1414
let mut app = tide::App::new();
1515
app.middleware(tide::middleware::RequestLogger::new());
16-
app.at("/").get(async move |_| "Hello, world!");
16+
app.at("/").get(|_| async move { "Hello, world!" });
1717
app.run("127.0.0.1:8000").unwrap();
1818
}

examples/runtime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(async_await, async_closure)]
1+
#![feature(async_await)]
22

33
/// An example of how to run a Tide service on top of `runtime`, this also shows the pieces
44
/// necessary if you wish to run a service on some other executor/IO source.
@@ -7,7 +7,7 @@
77
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
88
// First, we create a simple hello world application
99
let mut app = tide::App::new();
10-
app.at("/").get(async move |_| "Hello, world!");
10+
app.at("/").get(|_| async move { "Hello, world!" });
1111

1212
// Instead of using `App::run` to start the application, which implicitly uses a default
1313
// http-service server, we need to configure a custom server with the executor and IO source we

rfcs/001-app-new.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ __no state__
5252

5353
fn main() -> Result<(), failure::Error> {
5454
let mut app = tide::App::new();
55-
app.at("/").get(async move |_| "Hello, world!");
55+
app.at("/").get(|_| async move { "Hello, world!" });
5656
app.serve("127.0.0.1:8000")?;
5757
}
5858
```
@@ -68,7 +68,7 @@ struct State {
6868

6969
fn main() -> Result<(), failure::Error> {
7070
let mut app = tide::App::with_state(State::default());
71-
app.at("/").get(async move |_| "Hello, world!");
71+
app.at("/").get(|_| async move { "Hello, world!" });
7272
app.serve("127.0.0.1:8000")?;
7373
}
7474
```

src/app.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ use crate::{
3030
/// on `127.0.0.1:8000` with:
3131
///
3232
/// ```rust, no_run
33-
/// #![feature(async_await, async_closure)]
33+
/// #![feature(async_await)]
3434
///
3535
/// let mut app = tide::App::new();
36-
/// app.at("/hello").get(async move |_| "Hello, world!");
36+
/// app.at("/hello").get(|_| async move { "Hello, world!" });
3737
/// app.run("127.0.0.1:8000");
3838
/// ```
3939
///
@@ -45,7 +45,7 @@ use crate::{
4545
/// segments as parameters to endpoints:
4646
///
4747
/// ```rust, no_run
48-
/// #![feature(async_await, async_closure)]
48+
/// #![feature(async_await)]
4949
///
5050
/// use tide::error::ResultExt;
5151
///
@@ -63,7 +63,7 @@ use crate::{
6363
///
6464
/// app.at("/hello/:user").get(hello);
6565
/// app.at("/goodbye/:user").get(goodbye);
66-
/// app.at("/").get(async move |_| {
66+
/// app.at("/").get(|_| async move {
6767
/// "Use /hello/{your name} or /goodbye/{your name}"
6868
/// });
6969
///
@@ -166,9 +166,9 @@ impl<State: Send + Sync + 'static> App<State> {
166166
/// respective endpoint of the selected resource. Example:
167167
///
168168
/// ```rust,no_run
169-
/// # #![feature(async_await, async_closure)]
169+
/// # #![feature(async_await)]
170170
/// # let mut app = tide::App::new();
171-
/// app.at("/").get(async move |_| "Hello, world!");
171+
/// app.at("/").get(|_| async move { "Hello, world!" });
172172
/// ```
173173
///
174174
/// A path is comprised of zero or many segments, i.e. non-empty strings
@@ -337,9 +337,9 @@ mod tests {
337337
#[test]
338338
fn simple_static() {
339339
let mut router = App::new();
340-
router.at("/").get(async move |_| "/");
341-
router.at("/foo").get(async move |_| "/foo");
342-
router.at("/foo/bar").get(async move |_| "/foo/bar");
340+
router.at("/").get(|_| async move { "/" });
341+
router.at("/foo").get(|_| async move { "/foo" });
342+
router.at("/foo/bar").get(|_| async move { "/foo/bar" });
343343

344344
for path in &["/", "/foo", "/foo/bar"] {
345345
let res = block_on(simulate_request(&router, path, http::Method::GET));
@@ -351,23 +351,23 @@ mod tests {
351351
#[test]
352352
fn nested_static() {
353353
let mut router = App::new();
354-
router.at("/a").get(async move |_| "/a");
354+
router.at("/a").get(|_| async move { "/a" });
355355
router.at("/b").nest(|router| {
356-
router.at("/").get(async move |_| "/b");
357-
router.at("/a").get(async move |_| "/b/a");
358-
router.at("/b").get(async move |_| "/b/b");
356+
router.at("/").get(|_| async move { "/b" });
357+
router.at("/a").get(|_| async move { "/b/a" });
358+
router.at("/b").get(|_| async move { "/b/b" });
359359
router.at("/c").nest(|router| {
360-
router.at("/a").get(async move |_| "/b/c/a");
361-
router.at("/b").get(async move |_| "/b/c/b");
360+
router.at("/a").get(|_| async move { "/b/c/a" });
361+
router.at("/b").get(|_| async move { "/b/c/b" });
362362
});
363-
router.at("/d").get(async move |_| "/b/d");
363+
router.at("/d").get(|_| async move { "/b/d" });
364364
});
365365
router.at("/a/a").nest(|router| {
366-
router.at("/a").get(async move |_| "/a/a/a");
367-
router.at("/b").get(async move |_| "/a/a/b");
366+
router.at("/a").get(|_| async move { "/a/a/a" });
367+
router.at("/b").get(|_| async move { "/a/a/b" });
368368
});
369369
router.at("/a/b").nest(|router| {
370-
router.at("/").get(async move |_| "/a/b");
370+
router.at("/").get(|_| async move { "/a/b" });
371371
});
372372

373373
for failing_path in &["/", "/a/a", "/a/b/a"] {
@@ -393,9 +393,9 @@ mod tests {
393393
fn multiple_methods() {
394394
let mut router = App::new();
395395
router.at("/a").nest(|router| {
396-
router.at("/b").get(async move |_| "/a/b GET");
396+
router.at("/b").get(|_| async move { "/a/b GET" });
397397
});
398-
router.at("/a/b").post(async move |_| "/a/b POST");
398+
router.at("/a/b").post(|_| async move { "/a/b POST" });
399399

400400
for (path, method) in &[("/a/b", http::Method::GET), ("/a/b", http::Method::POST)] {
401401
let res = block_on(simulate_request(&router, path, method.clone()));

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
#![cfg_attr(any(feature = "nightly", test), feature(external_doc))]
66
#![cfg_attr(feature = "nightly", doc(include = "../README.md"))]
7-
#![feature(async_await, async_closure, existential_type)]
7+
#![feature(async_await, existential_type)]
88
#![warn(
99
nonstandard_style,
1010
rust_2018_idioms,

0 commit comments

Comments
 (0)