From 4a14c98e1a1f5c768f58f9ae1446a6f38b67f1b4 Mon Sep 17 00:00:00 2001 From: Ziyang Hu Date: Wed, 29 Nov 2023 22:37:44 +0800 Subject: [PATCH] Implements IntoIterator as suggested https://github.com/cozodb/cozo/issues/207 --- cozo-core/src/runtime/db.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cozo-core/src/runtime/db.rs b/cozo-core/src/runtime/db.rs index ea796ba5..90996a57 100644 --- a/cozo-core/src/runtime/db.rs +++ b/cozo-core/src/runtime/db.rs @@ -136,6 +136,15 @@ pub struct NamedRows { pub next: Option>, } +impl IntoIterator for NamedRows { + type Item = Tuple; + type IntoIter = std::vec::IntoIter; + + fn into_iter(self) -> Self::IntoIter { + self.rows.into_iter() + } +} + impl NamedRows { /// create a named rows with the given headers and rows pub fn new(headers: Vec, rows: Vec) -> Self {