sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

`FromRow` does not allow to derive immutable references in its structures

Open Luni-4 opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

Until now it is not possible to obtain immutable shared references deriving FromRow

#[derive(FromRow, Serialize, Deserialize)]
struct Foo<'r> {
    /// Name
    name: &'r str,
}

This behaviour would be really helpful when you have to read data contained in a structure without the necessity to modify anything. This also avoid further allocations when passing around the structure or inserting new data.

I have to admit that I have not analyzed the feasibility of this feature, therefore please close this issue whether it is deemed infeasible.

Describe the solution you'd like

Allow immutable references in FromRow derived-structures

Luni-4 avatar Nov 03 '23 09:11 Luni-4

Related: https://github.com/launchbadge/sqlx/issues/2661

qsantos avatar Jan 06 '24 19:01 qsantos