Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sync up with nightly futures_api #176

Merged
merged 13 commits into from
Apr 18, 2019
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: rust
rust:
- nightly-2019-02-27
- nightly-2019-04-16

before_script: |
rustup component add rustfmt clippy
Expand Down
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ 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.5"
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"
typemap = "0.3.3"

[dependencies.http-service-hyper]
optional = true
version = "0.1.0"
version = "0.1.1"

[dependencies.multipart]
default-features = false
Expand All @@ -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.1"
serde = "1.0.90"
serde_derive = "1.0.90"
20 changes: 19 additions & 1 deletion src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AppData>` as an argument and
/// In practice, endpoints are functions that take a `Context<AppData>` as an argument and
/// return a type `T` that implements [`IntoResponse`].
///
/// # Examples
Expand All @@ -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<Output = String> {
/// futures::future::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<AppData>: Send + Sync + 'static {
/// The async result of `call`.
type Fut: Future<Output = Response> + Send + 'static;
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
#![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.
Expand Down