From 83fd46b4f5095e8a5ef24f9b9a2682004d912b56 Mon Sep 17 00:00:00 2001 From: Yuriy Dupyn <2153100+omedusyo@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:29:05 +0100 Subject: [PATCH] Explain why implementing Debug for Response::Selected(...) is problematic --- minisql/src/interpreter.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/minisql/src/interpreter.rs b/minisql/src/interpreter.rs index 773eac1..89df2b2 100644 --- a/minisql/src/interpreter.rs +++ b/minisql/src/interpreter.rs @@ -35,10 +35,9 @@ impl std::fmt::Debug for Response<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { use Response::*; match self { - Selected(_schema, _columns, _rows) => - // TODO: How can we iterate through the rows without having to take ownership of - // them? - { + Selected(_schema, _columns, _rows) => { + // It seems that Rust requires ownership of rows to format them here. + // This is why we output the string below f.write_str("Some rows... trust me") } Inserted => f.write_str("Inserted"),