Advertisement
Guest User

infinite_loop

a guest
Sep 10th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. const std = @import("std");
  2.  
  3. const A = struct {
  4. val: i64,
  5. a_val: ?*A,
  6.  
  7. pub fn format(self: A, comptime fmt: []const u8, opt: std.fmt.FormatOptions, writer: anytype) !void {
  8. if (self.a_val) |a| {
  9. try writer.print("{} {}", .{ a.*, self.val }); // infinite loop issue
  10. }
  11. }
  12. };
  13.  
  14. pub fn main() !void {
  15. const a = A{ .val = 10, .a_val = null };
  16.  
  17. const str = try std.fmt.allocPrint(std.testing.allocator, "{}", .{a});
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement