From eafe50fbf07388c03d6e052031296265bbc55643 Mon Sep 17 00:00:00 2001 From: Jud Hembree Date: Wed, 11 Dec 2024 23:54:18 -0500 Subject: fixup README.md spanZ is no longer in the standard. Found an alternate way to run the example. Updating readme for the next guy. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b26708c..4454e9c 100644 --- a/README.md +++ b/README.md @@ -227,8 +227,8 @@ const row = try stmt.one( .{}, .{ .id = 20 }, ); -if (row) |row| { - std.log.debug("name: {}, age: {}", .{std.mem.spanZ(&row.name), row.age}); +if (row) |r| { + std.log.debug("name: {}, age: {}", .{std.mem.span((&row.name).ptr), row.age}); } ``` Notice that to read text we need to use a 0-terminated array; if the `name` column is bigger than 127 bytes the call to `one` will fail. -- cgit v1.2.3 From 8fe3f3c2595679941c2c609dbe18e8ed5da779ab Mon Sep 17 00:00:00 2001 From: Judsen Hembree Date: Fri, 13 Dec 2024 23:40:08 -0500 Subject: Update README.md Use suggested code edit. Co-authored-by: Vincent Rischmann --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4454e9c..07a9845 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,9 @@ const row = try stmt.one( .{ .id = 20 }, ); if (row) |r| { - std.log.debug("name: {}, age: {}", .{std.mem.span((&row.name).ptr), row.age}); + const name_ptr: [*:0]const u8 = &r.name; + std.log.debug("name: {s}, age: {}", .{ std.mem.span(name_ptr), r.age }); +} } ``` Notice that to read text we need to use a 0-terminated array; if the `name` column is bigger than 127 bytes the call to `one` will fail. -- cgit v1.2.3