sqlx
sqlx copied to clipboard
`FromRow` does not allow to derive immutable references in its structures
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
Related: https://github.com/launchbadge/sqlx/issues/2661