pub trait RowIteratorExt: Iterator<Item = Result<Row, Error>> + Sized {
// Required method
fn map_rows<T: FromRow>(self) -> MapRows<Self, T> ⓘ;
}Expand description
Extension trait for iterating over query results as typed structs.
This trait is automatically implemented for any iterator of Result<Row, Error>.
Required Methods§
Sourcefn map_rows<T: FromRow>(self) -> MapRows<Self, T> ⓘ
fn map_rows<T: FromRow>(self) -> MapRows<Self, T> ⓘ
Map each row to a struct implementing FromRow.
§Example
use mssql_client::{FromRow, RowIteratorExt};
#[derive(mssql_derive::FromRow)]
struct User { id: i32, name: String }
let users: Vec<User> = client
.query("SELECT id, name FROM users", &[])
.await?
.map_rows::<User>()
.collect::<Result<Vec<_>, _>>()?;Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".