I'm getting started with Rust and a SQLite database. Looking at the sqlx
Readme, they show some example code, which I modified a bit to:
let mut conn = connect_to_db().await?;
let mut stream = sqlx::query("SELECT * from cards limit 5")
.map(|row: SqliteRow| {
let id: String = row.try_get("id").unwrap();
Card { id }
}).fetch(&mut conn);
for card in stream.??? { // Don't know what to do here
println!("id = {}", card.id)
}
I just want to be able to iterate over the Cards
and get a Vec<Card>
for now.
I guessed stream.collect()
and stream.collect().into_iter()
. The latter gave an interesting error I haven't seen before.
error[E0599]: the method `into_iter` exists for struct
`Collect<Pin<Box<dyn Stream<Item = Result<Card, Error>> + Send>>, _>`,
but its trait bounds were not satisfied