authorgravatar for cawatson1993@gmail.comChris Watson <cawatson1993@gmail.com> 2020-06-30 19:52:02-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-07-01 22:22:30+00:00
logb8d5b3e6110023e17e1c191afa1d143f8b71fe4f
treef6ed3b9b44a74be51be07b5d695091678496783e
parent7eed220924062aa68586278568df6731afb2a20e

Add documentation for @src() builtin


1 files changed, 22 insertions(+), 0 deletions(-)

doc/langref.html.in+22
......@@ -8030,7 +8030,29 @@ test "vector @splat" {
80308030 </p>
80318031 {#see_also|Vectors|@shuffle#}
80328032 {#header_close#}
8033 {#header_open|@src#}
8034 <pre>{#syntax#}@src() std.builtin.SourceLocation{#endsyntax#}</pre>
8035 <p>
8036 Returns a {#syntax#}SourceLocation{#endsyntax#} struct representing the function's name and location in the source code. This must be called in a function.
8037 </p>
8038 {#code_begin|test#}
8039const std = @import("std");
8040const expect = std.testing.expect;
8041
8042test "@src" {
8043 doTheTest();
8044}
8045
8046fn doTheTest() void {
8047 const src = @src();
80338048
8049 expect(src.line == 9);
8050 expect(src.column == 17);
8051 expect(std.mem.endsWith(u8, src.fn_name, "doTheTest"));
8052 expect(std.mem.endsWith(u8, src.file, "test.zig"));
8053}
8054 {#code_end#}
8055 {#header_close#}
80348056 {#header_open|@sqrt#}
80358057 <pre>{#syntax#}@sqrt(value: var) @TypeOf(value){#endsyntax#}</pre>
80368058 <p>