Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Derive ToSql and FromSql implementations for generic data types #570

Open
@alexwl

Description

@alexwl

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp