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

Not found the implements of MapRow for closure #228

Closed
wyanlord opened this issue Apr 5, 2020 · 0 comments
Closed

Not found the implements of MapRow for closure #228

wyanlord opened this issue Apr 5, 2020 · 0 comments
Labels

Comments

@wyanlord
Copy link

wyanlord commented Apr 5, 2020

    let sql = "select id, username from t_user where id < ?";
    let mut stream = sqlx::query(sql).bind(3_i32).
        map::<_, User>(|row: MySqlRow| {
            Ok(User {
                id: row.get("id"),
                username: row.get("username"),
            })
        }).fetch(&pool);

    while let Some(user) = stream.next().await? {
        println!("{:?}", user);
    }
error[E0277]: the trait bound `[closure@src\main.rs:36:24: 41:10]: sqlx_core::query::MapRow<sqlx_core::mysql::database::MySql>` is not satisfied
  --> src\main.rs:36:9
   |
36 |         map::<_, User>(|row: MySqlRow| {
   |         ^^^ the trait `sqlx_core::query::MapRow<sqlx_core::mysql::database::MySql>` is not implemented for `[closure@src\main.rs:36:24: 41:10]`
@mehcode mehcode added the bug label Apr 5, 2020
@mehcode mehcode closed this as completed in 72bd933 Apr 8, 2020
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

2 participants