From c282321d2608e25482cf4f1bc1a955cac1b8c088 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:13:33 +0000 Subject: [PATCH 1/6] refactor: split register_csv into helper functions Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- stdlib/src/csv.rs | 104 +++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/stdlib/src/csv.rs b/stdlib/src/csv.rs index 33b6e035..b6f6d7d4 100644 --- a/stdlib/src/csv.rs +++ b/stdlib/src/csv.rs @@ -9,58 +9,9 @@ impl StdlibRegistry { let mut exports: HashMap> = HashMap::new(); - exports.insert( - "parse".to_string(), - Rc::new(StdFunction { - name: "parse".to_string(), - arity: 1, - callback: |_ctx, args| { - let csv = args[0].try_into_string()?; - let mut list = Vec::new(); - for line in csv.lines() { - let parts: Vec = line - .split(',') - .map(|s| RuntimeValue::Str(s.to_string())) - .collect(); - list.push(RuntimeValue::List { - items: Rc::new(RefCell::new(parts)), - is_const: false, - }); - } - Ok(RuntimeValue::List { - items: Rc::new(RefCell::new(list)), - is_const: false, - }) - }, - }), - ); + exports.insert("parse".to_string(), csv_parse_fn()); - exports.insert( - "stringify".to_string(), - Rc::new(StdFunction { - name: "stringify".to_string(), - arity: 1, - callback: |_ctx, args| { - let mut lines = Vec::new(); - if let RuntimeValue::List { items, .. } = &args[0] { - for row in items.borrow().iter() { - if let RuntimeValue::List { - items: row_items, .. - } = row - { - let parts: Vec = row_items - .borrow() - .iter() - .map(|item| item.try_into_string().unwrap_or_default()) - .collect(); - lines.push(parts.join(",")); - } - } - } - Ok(RuntimeValue::Str(lines.join("\n"))) - }, - }), - ); + exports.insert("stringify".to_string(), csv_stringify_fn()); self.register_module( "std.csv", @@ -74,6 +25,57 @@ impl StdlibRegistry { } } +fn csv_parse_fn() -> Rc { + Rc::new(StdFunction { + name: "parse".to_string(), + arity: 1, + callback: |_ctx, args| { + let csv = args[0].try_into_string()?; + let mut list = Vec::new(); + for line in csv.lines() { + let parts: Vec = line + .split(',') + .map(|s| RuntimeValue::Str(s.to_string())) + .collect(); + list.push(RuntimeValue::List { + items: Rc::new(RefCell::new(parts)), + is_const: false, + }); + } + Ok(RuntimeValue::List { + items: Rc::new(RefCell::new(list)), + is_const: false, + }) + }, + }) +} + +fn csv_stringify_fn() -> Rc { + Rc::new(StdFunction { + name: "stringify".to_string(), + arity: 1, + callback: |_ctx, args| { + let mut lines = Vec::new(); + if let RuntimeValue::List { items, .. } = &args[0] { + for row in items.borrow().iter() { + if let RuntimeValue::List { + items: row_items, .. + } = row + { + let parts: Vec = row_items + .borrow() + .iter() + .map(|item| item.try_into_string().unwrap_or_default()) + .collect(); + lines.push(parts.join(",")); + } + } + } + Ok(RuntimeValue::Str(lines.join("\n"))) + }, + }) +} + #[cfg(test)] mod tests { use super::*; From f28681177e66bc875afc721d0ea16680d7fa0606 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:35:42 +0000 Subject: [PATCH 2/6] refactor: split register_csv into helper functions Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> From 191c707253e560f40f7479aba407d5da22ff69d7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:46:31 +0000 Subject: [PATCH 3/6] refactor: split register_csv into helper functions Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> From 7b87ab2ff5a6ced7ec16f7823d7ffb931d00f2de Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 21:09:41 +0000 Subject: [PATCH 4/6] refactor: split register_csv into helper functions Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> From 94323307ad74a6b1e925612f94b315c8c68c69e9 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 28 Oct 2026 00:21:26 +0000 Subject: [PATCH 5/6] refactor: split register_csv into helper functions Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> From 3f8325f9020188b774df7569b08488a9461ffa51 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 28 Oct 2026 00:32:17 +0000 Subject: [PATCH 6/6] refactor: split register_csv into helper functions Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- stdlib/tests/stdlib_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/tests/stdlib_tests.rs b/stdlib/tests/stdlib_tests.rs index 05c13a8c..51fdb1dc 100644 --- a/stdlib/tests/stdlib_tests.rs +++ b/stdlib/tests/stdlib_tests.rs @@ -519,6 +519,7 @@ fn test_http_module() { let response = "HTTP/1.1 200 OK\r\nContent-Length: 13\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\nHello Server!"; let _ = stream.write_all(response.as_bytes()); let _ = stream.flush(); + let _ = stream.shutdown(std::net::Shutdown::Both); } });