Skip to content

Can't clone sqlx::Pool #1709

Answered by abonander
stanley355 asked this question in Q&A
Feb 16, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Have a look at this line in your code:

    let pool = Pool::<Postgres>::connect(&env::var("PG_URL").unwrap()).await;

connect() is an async fn returning sqlx::Result<Pool>. You have to extract the Pool from that Result to use it.

The Rust Programming Language book has a chapter on this: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@stanley355
Comment options

Answer selected by abonander
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1708 on February 16, 2022 01:11.