From d342dfe30a2abf2b02317548ac0a08a937f4a942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Przytu=C5=82a?= Date: Tue, 12 Nov 2024 16:07:51 +0100 Subject: [PATCH] iterator: fix QueryPager::rows_stream() lifetime constraints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It appears that the previous requirements: ```rust fn rows_stream< 'frame, 'metadata, RowT: 'static + DeserializeRow<'frame, 'metadata> > ``` allowed creating the `TypedRowStream<&'static str>`. It was error-prone, because the compiler would accept `rows_stream::<&str>`, happily deducing that it's `&'static str`, and failing upon Stream `next()` not being a lending method. To prevent such situations, the constraints are changed the following way (credits to @Lorak-mmk): ```rust fn rows_stream< RowT: 'static + for<'frame, 'metadata> DeserializeRow<'frame, 'metadata> > ``` and now `&'static str` is not permitted (because it only implements `DeserializeValue<'static, '_>`. Co-authored-by: Karol BaryƂa --- scylla/src/transport/iterator.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scylla/src/transport/iterator.rs b/scylla/src/transport/iterator.rs index cb51471b0..160819f6c 100644 --- a/scylla/src/transport/iterator.rs +++ b/scylla/src/transport/iterator.rs @@ -663,12 +663,9 @@ impl QueryPager { /// It only allows deserializing owned types, because [Stream] is not lending. /// Begins with performing type check. #[inline] - pub fn rows_stream<'frame, 'metadata, RowT: 'static + DeserializeRow<'frame, 'metadata>>( + pub fn rows_stream DeserializeRow<'frame, 'metadata>>( self, - ) -> Result, TypeCheckError> - where - 'frame: 'metadata, - { + ) -> Result, TypeCheckError> { TypedRowLendingStream::::new(self).map(|typed_row_lending_stream| TypedRowStream { typed_row_lending_stream, })