Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The example doesn't work with latest version 0.14.12 #68

Open
@chiro-hiro

Description

The given code on your home page:

use std::{convert::Infallible, net::SocketAddr};
use hyper::{Body, Request, Response, Server};
use hyper::service::{make_service_fn, service_fn};
async fn handle(_: Request<Body>) -> Result<Response<Body>, Infallible> {
 Ok(Response::new("Hello, World!".into()))
}
#[tokio::main]
async fn main() {
 let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
 let make_svc = make_service_fn(|_conn| async {
 Ok::<_, Infallible>(service_fn(handle))
 });
 let server = Server::bind(&addr).serve(make_svc);
 if let Err(e) = server.await {
 eprintln!("server error: {}", e);
 }
}

The result:

 Compiling http-server v0.1.0 (/Users/chiro/GitHub/rust-playground/http-server)
error[E0432]: unresolved import `hyper::Server`
 --> src/main.rs:2:38
 |
2 | use hyper::{Body, Request, Response, Server};
 | ^^^^^^ no `Server` in the root
error: aborting due to previous error
For more information about this error, try `rustc --explain E0432`.
error: could not compile `http-server`
To learn more, run the command again with --verbose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /