@@ -10,19 +10,21 @@ pub const std_options: std.Options = .{
1010
1111fn getWeather (completed : * std .atomic .Value (u32 ), allocator : std .mem .Allocator , city : []const u8 , lang : []const u8 ) anyerror ! []const u8 {
1212 defer _ = completed .fetchAdd (1 , .monotonic );
13- var url : std .BoundedArray (u8 , 256 ) = .{};
13+ var buf : [256 ]u8 = undefined ;
14+ var url : std .ArrayListUnmanaged (u8 ) = .initBuffer (& buf );
1415 if (builtin .target .os .tag == .windows ) {
15- try url .writer ().print ("https://wttr.in/{s}?AFT&lang={s}" , .{ city , lang });
16+ try url .fixedWriter ().print ("https://wttr.in/{s}?AFT&lang={s}" , .{ city , lang });
1617 } else {
17- try url .writer ().print ("https://wttr.in/{s}?AF&lang={s}" , .{ city , lang });
18+ try url .fixedWriter ().print ("https://wttr.in/{s}?AF&lang={s}" , .{ city , lang });
1819 }
1920 var body = std .ArrayList (u8 ).init (allocator );
2021 errdefer body .deinit ();
2122 var client : std.http.Client = .{ .allocator = allocator };
2223 defer client .deinit ();
24+ var writer = body .writer ().adaptToNewApi ();
2325 _ = try client .fetch (.{
24- .location = .{ .url = url . constSlice () },
25- .response_storage = .{ . dynamic = & body } ,
26+ .location = .{ .url = & buf },
27+ .response_writer = & writer . new_interface ,
2628 });
2729 return body .toOwnedSlice ();
2830}
@@ -33,9 +35,10 @@ fn getLatestZig(completed: *std.atomic.Value(u32), allocator: std.mem.Allocator)
3335 defer body .deinit ();
3436 var client : std.http.Client = .{ .allocator = allocator };
3537 defer client .deinit ();
38+ var writer = body .writer ().adaptToNewApi ();
3639 _ = try client .fetch (.{
3740 .location = .{ .url = "https://ziglang.org/download/index.json" },
38- .response_storage = .{ . dynamic = & body } ,
41+ .response_writer = & writer . new_interface ,
3942 });
4043 const Index = struct {
4144 master : struct { version : []const u8 },
@@ -102,18 +105,20 @@ pub fn main() !void {
102105 // don't really have to call this, but I want the defer that cleans the progress bar to run
103106 ltask .cancel ();
104107
108+ var buf : [std .heap .pageSize ()]u8 = undefined ;
109+ var writer = std .fs .File .stdout ().writer (& buf );
105110 for (tasks .items , 0.. ) | task , idx | {
106111 if (task .complete (.wait )) | body | {
107112 defer allocator .free (body );
108113 if (idx == 3 ) {
109- try std . io . getStdOut (). writer () .print ("\n Aaand the current master zig version is... " , .{});
114+ try writer . interface .print ("\n Aaand the current master zig version is... " , .{});
110115 }
111- try std . io . getStdOut () .writeAll (body );
112- try std . io . getStdOut () .writeAll ("\n " );
116+ try writer . interface .writeAll (body );
117+ try writer . interface .writeAll ("\n " );
113118 } else | err | {
114- try std . io . getStdOut (). writer () .print ("request {} failed with: {}\n " , .{ idx , err });
119+ try writer . interface .print ("request {} failed with: {}\n " , .{ idx , err });
115120 }
116121 }
117122
118- try std . io . getStdOut (). writer () .print ("\n That's all folks\n " , .{});
123+ try writer . interface .print ("\n That's all folks\n " , .{});
119124}
0 commit comments