-
-
Notifications
You must be signed in to change notification settings - Fork 504
Open
Description
At the moment, it is impossible to derive FromSql
or ToSql
for a data type with generic parameters.
#[derive(FromSql)]
struct Data<'a> {
id: i32,
description: &'a str,
}
Error: missing lifetime specifier
#[derive(ToSql)]
struct Data<T: ToSql> {
id: i32,
description: String,
links: Vec<T>,
}
Error: wrong number of type arguments
The generated code for FromSql
and ToSql
doesn't take into account the fact that a structure may have lifetime or type parameters:
rust-postgres/postgres-derive/src/fromsql.rs
Lines 62 to 64 in cc9b823
impl<'a> postgres_types::FromSql<'a> for #ident { | |
fn from_sql(_type: &postgres_types::Type, buf: &'a [u8]) | |
-> std::result::Result<#ident, |
impl postgres_types::ToSql for #ident { |
Adding support for lifetimes should be relatively straightforward, not sure about type parameters though.
schneiderfelipe
Metadata
Metadata
Assignees
Labels
No labels