- Notifications
You must be signed in to change notification settings - Fork516
Open
Description
At the moment, it is impossible to deriveFromSql
orToSql
for a data type with generic parameters.
#[derive(FromSql)]structData<'a>{id:i32,description:&'astr,}
Error: missing lifetime specifier
#[derive(ToSql)]structData<T:ToSql>{id:i32,description:String,links:Vec<T>,}
Error: wrong number of type arguments
The generated code forFromSql
andToSql
doesn't take into account the fact that a structure may have lifetime or type parameters:
https://github.com/sfackler/rust-postgres/blob/cc9b8232a858099e11f8b9e8632566f9b6103a81/postgres-derive/src/fromsql.rs#L62-L64
https://github.com/sfackler/rust-postgres/blob/cc9b8232a858099e11f8b9e8632566f9b6103a81/postgres-derive/src/tosql.rs#L59
Adding support for lifetimes should be relatively straightforward, not sure about type parameters though.
Metadata
Metadata
Assignees
Labels
No labels