Undeclared Error


use std::env;
use std::io;

fn main() -> io::Result<()> {
env::set_var("RUST_LOG", "actix_web=debug,actix_server=info");

HttpServer::new(|| {
        // enable logger - always register actix-web Logger middleware last
        // register HTTP requests handlers


In this code I am getting error as follow.
failed to resolve: use of undeclared type HttpServer
failed to resolve: use of undeclared type App

Help me out somone

You need to add HttpServer and App to your imports

I am importing like this.

use HttpServer;
use App;

But it showing following error.
unresolved import HttpServer
no external crate HttpServer

same for App.

Those crates don't exit. App and HttpServer should be structs exported from whatever framework you are trying to use.

Look again at how it's done in the tutorial you are following.

It has links to full source code below the example. Click main.rs source code

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.