You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This causes the compiler to complain that "builder does not live long enough", as apparently it's dropped when the function ends, but is still borrowed (according to the compiler anyway).
I can work around this, by adding 'c to Arguments, like so:
This lets me compile the function, but calling it with the Sqlite driver causes another compilation error, namely that "implementation of IntoArguments is not general enough".
Converting 'q to be a named lifetime does not work either:
But obviously, the latter is undesirable, as it is meant to be a driver-agnostic function.
My question is: What am I missing here? I was looking at sqlx' trait bounds for Database, Arguments, IntoArguments, Execute, and Executor but didn't manage to find anything. Is it even possible to get a function like this to compile with the current API?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, I'm currently having an issue with using
QueryBuilder
in conjunction with generics. Consider the following minimal example:This causes the compiler to complain that "
builder
does not live long enough", as apparently it's dropped when the function ends, but is still borrowed (according to the compiler anyway).I can work around this, by adding
'c
toArguments
, like so:This lets me compile the function, but calling it with the
Sqlite
driver causes another compilation error, namely that "implementation ofIntoArguments
is not general enough".Converting
'q
to be a named lifetime does not work either:As in this scenario, the compiler mentions that "
builder
does not live long enough" as "argument requires thatbuilder
is borrowed for'q
".Finally, for good measure, if I just specify the
Sqlite
driver directly, the function does compile and can be called properly:But obviously, the latter is undesirable, as it is meant to be a driver-agnostic function.
My question is: What am I missing here? I was looking at sqlx' trait bounds for
Database
,Arguments
,IntoArguments
,Execute
, andExecutor
but didn't manage to find anything. Is it even possible to get a function like this to compile with the current API?Beta Was this translation helpful? Give feedback.
All reactions