diff --git a/scylla/src/transport/iterator.rs b/scylla/src/transport/iterator.rs index 5bbcb1c53..095e4957d 100644 --- a/scylla/src/transport/iterator.rs +++ b/scylla/src/transport/iterator.rs @@ -1175,3 +1175,29 @@ mod legacy { impl Unpin for LegacyTypedRowIterator {} } pub use legacy::{LegacyRowIterator, LegacyTypedRowIterator, NextRowError}; + +#[cfg(test)] +mod tests { + use super::*; + + // This test would confirm TypedRowLendingStream's power - if it worked... + // The present approach, however, requires borrowing TypedRowLendingStream + // for its whole lifetime (due to `&'a mut T` invariance wrt `T`). + // At the moment, we are unable to work around this problem. + // It would work if `next` method (instead of the TypedRowLendingStream itself) + // was generic over deserialized type, but then we would lose the + // "already type-checked against type T" guarantee embedded in + // `TypedRowLendingStream` type. + async fn _rows_lending_stream_allows_deserializing_borrowed_types() { + // Separate function to hide `unimplemented!()` at the call site from the compiler. + fn create_raw_stream() -> QueryPager { + unimplemented!(); + } + + let raw_stream: QueryPager = create_raw_stream(); + let mut typed = TypedRowLendingStream::new(raw_stream).unwrap(); + while let Some(row) = typed.next().await { + let _row: (&str,) = row.unwrap(); + } + } +}