From 8bd8fe795b84280aabb9cc403dc141736bce1d30 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Wed, 17 Apr 2019 02:52:31 +0530 Subject: [PATCH 01/11] fix: sync up with nightly futures_api --- .travis.yml | 2 +- Cargo.toml | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c882b3c5..f704cd386 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust rust: - - nightly-2019-02-27 + - nightly-2019-04-15 before_script: | rustup component add rustfmt clippy diff --git a/Cargo.toml b/Cargo.toml index f0ef76fdf..ee05176eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,16 +14,16 @@ version = "0.1.0" [dependencies] cookie = "0.11" -futures-preview = "0.3.0-alpha.13" +futures-preview = "0.3.0-alpha.14" fnv = "1.0.6" http = "0.1" -http-service = "0.1.4" +http-service = "0.1.4" # TODO: update after release pin-utils = "0.1.0-alpha.4" route-recognizer = "0.1.12" -serde = "1.0.80" -serde_derive = "1.0.80" -serde_json = "1.0.32" -serde_qs = "0.4.1" +serde = "1.0.90" +serde_derive = "1.0.90" +serde_json = "1.0.39" +serde_qs = "0.4.5" slog = "2.4.1" slog-async = "2.3.0" slog-term = "2.4.0" @@ -31,7 +31,7 @@ typemap = "0.3.3" [dependencies.http-service-hyper] optional = true -version = "0.1.0" +version = "0.1.0" # TODO: update after release [dependencies.multipart] default-features = false @@ -45,7 +45,7 @@ hyper = ["http-service-hyper"] [dev-dependencies] basic-cookies = "0.1.3" juniper = "0.10.0" -structopt = "0.2.14" -http-service-mock = "0.1.0" -serde = "1.0.80" -serde_derive = "1.0.80" +structopt = "0.2.15" +http-service-mock = "0.1.0" # TODO: update after release +serde = "1.0.90" +serde_derive = "1.0.90" From f988b7e492c3cc6c1b00527bc031f6e84c757dc3 Mon Sep 17 00:00:00 2001 From: "Prasanna V. Loganathar" Date: Thu, 18 Apr 2019 02:12:05 +0530 Subject: [PATCH 02/11] update dep versions Now that https://github.com/rustasync/http-service/pull/14 has landed, update dep versions. (Though this also requires https://github.com/rustasync/http-service/pull/17 now) --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ee05176eb..fc8e44803 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ cookie = "0.11" futures-preview = "0.3.0-alpha.14" fnv = "1.0.6" http = "0.1" -http-service = "0.1.4" # TODO: update after release +http-service = "0.1.5" pin-utils = "0.1.0-alpha.4" route-recognizer = "0.1.12" serde = "1.0.90" @@ -31,7 +31,7 @@ typemap = "0.3.3" [dependencies.http-service-hyper] optional = true -version = "0.1.0" # TODO: update after release +version = "0.1.1" [dependencies.multipart] default-features = false @@ -46,6 +46,6 @@ hyper = ["http-service-hyper"] basic-cookies = "0.1.3" juniper = "0.10.0" structopt = "0.2.15" -http-service-mock = "0.1.0" # TODO: update after release +http-service-mock = "0.1.1" serde = "1.0.90" serde_derive = "1.0.90" From 85fac1a2c764c8b50c7a45d70cdcc0f027359f30 Mon Sep 17 00:00:00 2001 From: "Prasanna V. Loganathar" Date: Thu, 18 Apr 2019 02:29:57 +0530 Subject: [PATCH 03/11] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f704cd386..15c6e324e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust rust: - - nightly-2019-04-15 + - nightly-2019-04-16 before_script: | rustup component add rustfmt clippy From 9e0a19ad2ed6168737a44d9f82c00453f9ef8260 Mon Sep 17 00:00:00 2001 From: Allen Date: Wed, 17 Apr 2019 14:12:58 -0700 Subject: [PATCH 04/11] Documents acceptable endpoint fns (#177) * expand on endpoint Fn's * use ready! macro instead --- src/endpoint.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/endpoint.rs b/src/endpoint.rs index 2333f00f2..4a0619809 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -7,7 +7,7 @@ use crate::{response::IntoResponse, Context, Response}; /// This trait is automatically implemented for `Fn` types, and so is rarely implemented /// directly by Tide users. /// -/// In practice, endpoints are function that take a `Context` as an argument and +/// In practice, endpoints are functions that take a `Context` as an argument and /// return a type `T` that implements [`IntoResponse`]. /// /// # Examples @@ -31,6 +31,24 @@ use crate::{response::IntoResponse, Context, Response}; /// app.serve("127.0.0.1:8000").unwrap() /// } /// ``` +/// +/// An endpoint with similar functionality that does not make use of the `async` keyword would look something like this: +/// +/// ```rust, no_run +/// # #![feature(futures_api)] +/// # use core::future::Future; +/// fn hello(_cx: tide::Context<()>) -> impl Future { +/// futures::ready!(String::from("hello")) +/// } +/// +/// fn main() { +/// let mut app = tide::App::new(()); +/// app.at("/hello").get(hello); +/// app.serve("127.0.0.1:8000").unwrap() +/// } +/// ``` +/// +/// Tide routes will also accept endpoints with `Fn` signatures of this form, but using the `async` keyword has better ergonomics. pub trait Endpoint: Send + Sync + 'static { /// The async result of `call`. type Fut: Future + Send + 'static; From b09fcdaee34e338e178a8ce51d0bd52b621e5570 Mon Sep 17 00:00:00 2001 From: "Prasanna V. Loganathar" Date: Thu, 18 Apr 2019 18:31:21 +0530 Subject: [PATCH 05/11] compiler pragmas Add some good practise pragmas. Additionally, this also worksaround clippy bug allowing it to pass with the addition of crate level `#![allow(clippy::needless_lifetimes)]`. It's applied on a crate level so as to avoid this from being added repeatedly across the modules or functions - and since it's strictly a temporary measure. Related: https://github.com/rustasync/tide/pull/176 --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e9aa72b0d..0e7afadda 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,8 +2,14 @@ #![cfg_attr(feature = "nightly", feature(external_doc))] #![cfg_attr(feature = "nightly", doc(include = "../README.md"))] #![cfg_attr(test, deny(warnings))] -#![allow(unused_variables)] #![feature(futures_api, async_await, await_macro, existential_type)] +#![allow(unused_variables)] +#![deny(nonstandard_style)] +#![forbid(rust_2018_idioms)] + +// Remove this clippy bug with async await is resolved. +// ISSUE: https://github.com/rust-lang/rust-clippy/issues/3988 +#![allow(clippy::needless_lifetimes)] //! //! Welcome to Tide. From 0281fa671cafa9761f08282c5df823bb13c3082d Mon Sep 17 00:00:00 2001 From: "Prasanna V. Loganathar" Date: Thu, 18 Apr 2019 18:33:08 +0530 Subject: [PATCH 06/11] fix: 2018 edition lints --- src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index 8999eac9e..068cfc04b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -13,7 +13,7 @@ pub struct StringError(pub String); impl std::error::Error for StringError {} impl std::fmt::Display for StringError { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { self.0.fmt(f) } } From 69c0c60bacef29dd0e0071c799ace3a2f0977aaa Mon Sep 17 00:00:00 2001 From: "Prasanna V. Loganathar" Date: Thu, 18 Apr 2019 18:43:42 +0530 Subject: [PATCH 07/11] fix: cargo fmt check in the last commit --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0e7afadda..e383c1982 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,6 @@ #![allow(unused_variables)] #![deny(nonstandard_style)] #![forbid(rust_2018_idioms)] - // Remove this clippy bug with async await is resolved. // ISSUE: https://github.com/rust-lang/rust-clippy/issues/3988 #![allow(clippy::needless_lifetimes)] From 8b478bc9597a199198b79d4c0d32d1b955f1e7e4 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Wed, 17 Apr 2019 02:52:31 +0530 Subject: [PATCH 08/11] fix: sync up with nightly futures_api --- .travis.yml | 2 +- Cargo.toml | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c882b3c5..f704cd386 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust rust: - - nightly-2019-02-27 + - nightly-2019-04-15 before_script: | rustup component add rustfmt clippy diff --git a/Cargo.toml b/Cargo.toml index f0ef76fdf..ee05176eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,16 +14,16 @@ version = "0.1.0" [dependencies] cookie = "0.11" -futures-preview = "0.3.0-alpha.13" +futures-preview = "0.3.0-alpha.14" fnv = "1.0.6" http = "0.1" -http-service = "0.1.4" +http-service = "0.1.4" # TODO: update after release pin-utils = "0.1.0-alpha.4" route-recognizer = "0.1.12" -serde = "1.0.80" -serde_derive = "1.0.80" -serde_json = "1.0.32" -serde_qs = "0.4.1" +serde = "1.0.90" +serde_derive = "1.0.90" +serde_json = "1.0.39" +serde_qs = "0.4.5" slog = "2.4.1" slog-async = "2.3.0" slog-term = "2.4.0" @@ -31,7 +31,7 @@ typemap = "0.3.3" [dependencies.http-service-hyper] optional = true -version = "0.1.0" +version = "0.1.0" # TODO: update after release [dependencies.multipart] default-features = false @@ -45,7 +45,7 @@ hyper = ["http-service-hyper"] [dev-dependencies] basic-cookies = "0.1.3" juniper = "0.10.0" -structopt = "0.2.14" -http-service-mock = "0.1.0" -serde = "1.0.80" -serde_derive = "1.0.80" +structopt = "0.2.15" +http-service-mock = "0.1.0" # TODO: update after release +serde = "1.0.90" +serde_derive = "1.0.90" From b120ba287d134df21c87515fa0e0d44fb91e1c3c Mon Sep 17 00:00:00 2001 From: "Prasanna V. Loganathar" Date: Thu, 18 Apr 2019 02:12:05 +0530 Subject: [PATCH 09/11] update dep versions Now that https://github.com/rustasync/http-service/pull/14 has landed, update dep versions. (Though this also requires https://github.com/rustasync/http-service/pull/17 now) --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ee05176eb..fc8e44803 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ cookie = "0.11" futures-preview = "0.3.0-alpha.14" fnv = "1.0.6" http = "0.1" -http-service = "0.1.4" # TODO: update after release +http-service = "0.1.5" pin-utils = "0.1.0-alpha.4" route-recognizer = "0.1.12" serde = "1.0.90" @@ -31,7 +31,7 @@ typemap = "0.3.3" [dependencies.http-service-hyper] optional = true -version = "0.1.0" # TODO: update after release +version = "0.1.1" [dependencies.multipart] default-features = false @@ -46,6 +46,6 @@ hyper = ["http-service-hyper"] basic-cookies = "0.1.3" juniper = "0.10.0" structopt = "0.2.15" -http-service-mock = "0.1.0" # TODO: update after release +http-service-mock = "0.1.1" serde = "1.0.90" serde_derive = "1.0.90" From 4cc8865b0e3973469a3bbcde787e61cf36262c9e Mon Sep 17 00:00:00 2001 From: "Prasanna V. Loganathar" Date: Thu, 18 Apr 2019 02:29:57 +0530 Subject: [PATCH 10/11] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f704cd386..15c6e324e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust rust: - - nightly-2019-04-15 + - nightly-2019-04-16 before_script: | rustup component add rustfmt clippy From 8b88cac767b19b425338e63dd27635d43824443e Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Thu, 18 Apr 2019 19:34:16 +0530 Subject: [PATCH 11/11] fix: docs using old futures macro --- src/endpoint.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/endpoint.rs b/src/endpoint.rs index 4a0619809..7be5b8d28 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -38,7 +38,7 @@ use crate::{response::IntoResponse, Context, Response}; /// # #![feature(futures_api)] /// # use core::future::Future; /// fn hello(_cx: tide::Context<()>) -> impl Future { -/// futures::ready!(String::from("hello")) +/// futures::future::ready(String::from("hello")) /// } /// /// fn main() {