1
1
const std = @import ("std" );
2
+ const print = @import ("../../include/zig/print.zig" );
2
3
const builtin = @import ("builtin" );
3
4
const math = std .math ;
4
5
const Allocator = std .mem .Allocator ;
@@ -14,7 +15,7 @@ pub fn main() !void {
14
15
const stretch_depth = max_depth + 1 ;
15
16
const stretch_tree = Node .make (stretch_depth , global_allocator ).? ;
16
17
defer stretch_tree .deinit ();
17
- try printFmt ("stretch tree of depth {d}\t check: {d}\n " , .{ stretch_depth , stretch_tree .check () });
18
+ try print . printFmt ("stretch tree of depth {d}\t check: {d}\n " , .{ stretch_depth , stretch_tree .check () });
18
19
}
19
20
const long_lived_tree = Node .make (max_depth , global_allocator ).? ;
20
21
defer long_lived_tree .deinit ();
@@ -29,10 +30,10 @@ pub fn main() !void {
29
30
defer tree .deinit ();
30
31
sum += tree .check ();
31
32
}
32
- try printFmt ("{d}\t trees of depth {d}\t check: {d}\n " , .{ iterations , depth , sum });
33
+ try print . printFmt ("{d}\t trees of depth {d}\t check: {d}\n " , .{ iterations , depth , sum });
33
34
}
34
35
35
- try printFmt ("long lived tree of depth {d}\t check: {d}\n " , .{ max_depth , long_lived_tree .check () });
36
+ try print . printFmt ("long lived tree of depth {d}\t check: {d}\n " , .{ max_depth , long_lived_tree .check () });
36
37
}
37
38
38
39
fn get_n () ! usize {
@@ -42,12 +43,6 @@ fn get_n() !usize {
42
43
return @as (usize , @intCast (try std .fmt .parseInt (u32 , arg , 10 )));
43
44
}
44
45
45
- fn printFmt (comptime fmt : []const u8 , args : anytype ) ! void {
46
- var buf : [256 ]u8 = undefined ;
47
- const out = try std .fmt .bufPrint (& buf , fmt , args );
48
- _ = try std .posix .write (std .posix .STDOUT_FILENO , out );
49
- }
50
-
51
46
const Node = struct {
52
47
const Self = @This ();
53
48
0 commit comments