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

error[E0277]: the trait bound PreEscaped<String>: Responder is not satisfied #330

Closed
g-cyan opened this issue Feb 1, 2022 · 4 comments
Closed
Labels

Comments

@g-cyan
Copy link

g-cyan commented Feb 1, 2022

In this page of Actix , I copied the codes.

https://maud.lambda.xyz/web-frameworks.html

use actix_web::{get, App, HttpServer, Result as AwResult};
use maud::{html, Markup};
use std::io;

#[get("/")]
async fn index() -> AwResult<Markup> {
    Ok(html! {
        html {
            body {
                h1 { "Hello World!" }
            }
        }
    })
}

#[actix_web::main]
async fn main() -> io::Result<()> {
    HttpServer::new(|| App::new().service(index))
        .bind(("127.0.0.1", 8080))?
        .run()
        .await
}

The error spilled out as follows.

error[E0277]: the trait bound `PreEscaped<String>: Responder` is not satisfied
   --> src/main.rs:5:1
    |
5   | #[get("/")]
    | ^^^^^^^^^^^ the trait `Responder` is not implemented for `PreEscaped<String>`

What can I do for next?

@lambda-fairy
Copy link
Owner

Hi @g-cyan, sorry about the late reply.

What's the contents of your Cargo.toml and Cargo.lock? This usually happens when the actix-web version is not compatible. Or the feature is not enabled.

@g-cyan
Copy link
Author

g-cyan commented Feb 28, 2022

actix-web = "3.3.3" works perfectly so far with above code. I think the above error message is thrown as I had used version 4 of actix -web.

@g-cyan g-cyan closed this as completed Feb 28, 2022
@penso
Copy link

penso commented Jul 6, 2022

I have the same issue with actix4.

@penso
Copy link

penso commented Jul 6, 2022

Note: adding the git repo fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants