Added docstrings to structure functions.

This commit is contained in:
KikooDX 2021-01-26 14:46:32 +01:00
parent c07858308a
commit 44a2333093
3 changed files with 7 additions and 1 deletions

View File

@ -11,7 +11,7 @@ pub fn build(b: *Builder) void {
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("zigraylib", "src/main.zig");
const exe = b.addExecutable("kble", "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
exe.install();

View File

@ -10,6 +10,8 @@ width: u16,
height: u16,
buffer: []cell_t,
/// Create structure and allocate required memory. The `buffer` array size will
/// be equal to `width` times `height`.
pub fn init(allocator: *std.mem.Allocator, width: u16, height: u16) !Self {
var level = Self{
.width = width,
@ -20,6 +22,7 @@ pub fn init(allocator: *std.mem.Allocator, width: u16, height: u16) !Self {
return level;
}
/// Free the level buffer.
pub fn deinit(self: *Self, allocator: *std.mem.Allocator) void {
allocator.free(self.buffer);
}

View File

@ -7,6 +7,7 @@ const Self = @This();
x: i32,
y: i32,
/// Create a vector with `x` and `y` values.
pub fn init(x: i32, y: i32) Self {
return Self {
.x = x,
@ -14,6 +15,7 @@ pub fn init(x: i32, y: i32) Self {
};
}
/// Return the sum of `self` and `other`.
pub fn add(self: Self, other: Self) Self {
return Self {
.x = self.x + other.x,
@ -21,6 +23,7 @@ pub fn add(self: Self, other: Self) Self {
};
}
/// Return the difference between `self` and `other`.
pub fn sub(self: Self, other: Self) Self {
return Self {
.x = self.x - other.x,