summaryrefslogtreecommitdiff
path: root/clap/codepoint_counting_writer.zig
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2024-10-22 17:46:47 +0200
committerGravatar Jimmi Holst Christensen2024-10-22 17:48:34 +0200
commite73b56aa4bcb7e53144ef96ee978f2a19b32669d (patch)
tree0ab5e3d426e25d2ad9d2e0cd0015fc010d9ea182 /clap/codepoint_counting_writer.zig
parentfeat: Add `terminating_positional` to `clap.ParseOptions` (diff)
downloadzig-clap-e73b56aa4bcb7e53144ef96ee978f2a19b32669d.tar.gz
zig-clap-e73b56aa4bcb7e53144ef96ee978f2a19b32669d.tar.xz
zig-clap-e73b56aa4bcb7e53144ef96ee978f2a19b32669d.zip
refactor: Always access using full namespace
This is my new preferred style of programming Zig :)
Diffstat (limited to 'clap/codepoint_counting_writer.zig')
-rw-r--r--clap/codepoint_counting_writer.zig7
1 files changed, 3 insertions, 4 deletions
diff --git a/clap/codepoint_counting_writer.zig b/clap/codepoint_counting_writer.zig
index e6b9d1c..c445c90 100644
--- a/clap/codepoint_counting_writer.zig
+++ b/clap/codepoint_counting_writer.zig
@@ -1,7 +1,3 @@
1const std = @import("std");
2const builtin = @import("builtin");
3const native_endian = builtin.cpu.arch.endian();
4
5/// A Writer that counts how many codepoints has been written to it. 1/// A Writer that counts how many codepoints has been written to it.
6/// Expects valid UTF-8 input, and does not validate the input. 2/// Expects valid UTF-8 input, and does not validate the input.
7pub fn CodepointCountingWriter(comptime WriterType: type) type { 3pub fn CodepointCountingWriter(comptime WriterType: type) type {
@@ -34,6 +30,7 @@ pub fn CodepointCountingWriter(comptime WriterType: type) type {
34// the number of codepoints up to that point. 30// the number of codepoints up to that point.
35// Does not validate UTF-8 beyond checking the start byte. 31// Does not validate UTF-8 beyond checking the start byte.
36fn utf8CountCodepointsAllowTruncate(s: []const u8) !struct { bytes: usize, codepoints: usize } { 32fn utf8CountCodepointsAllowTruncate(s: []const u8) !struct { bytes: usize, codepoints: usize } {
33 const native_endian = @import("builtin").cpu.arch.endian();
37 var len: usize = 0; 34 var len: usize = 0;
38 35
39 const N = @sizeOf(usize); 36 const N = @sizeOf(usize);
@@ -100,3 +97,5 @@ test "handles partial UTF-8 writes" {
100 97
101 try testing.expectEqualSlices(u8, utf8_text, fbs.getWritten()); 98 try testing.expectEqualSlices(u8, utf8_text, fbs.getWritten());
102} 99}
100
101const std = @import("std");