TopLevelFields.zig (524B) - Raw
1 //! Because this file contains fields, it is a type which is intended to be instantiated, and so 2 //! is named in TitleCase instead of snake_case by convention. 3 4 foo: u32, 5 bar: u64, 6 7 /// `@This()` can be used to refer to this struct type. In files with fields, it is quite common to 8 /// name the type here, so it can be easily referenced by other declarations in this file. 9 const TopLevelFields = @This(); 10 11 pub fn init(val: u32) TopLevelFields { 12 return .{ 13 .foo = val, 14 .bar = val * 10, 15 }; 16 } 17 18 // syntax