From eb723a407073592db858cf14bece8643bec2a771 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 19 Mar 2024 12:46:38 +0100 Subject: Update uses of `@fieldParentPtr` to use RLS --- doc/langref.html.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/langref.html.in b/doc/langref.html.in index 4ad6b3f866..f494574036 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -3107,7 +3107,7 @@ test "struct namespaced variable" { // struct field order is determined by the compiler for optimal performance. // however, you can still calculate a struct base pointer given a field pointer: fn setYBasedOnX(x: *f32, y: f32) void { - const point = @fieldParentPtr(Point, "x", x); + const point: *Point = @fieldParentPtr("x", x); point.y = y; } test "field parent pointer" { @@ -8757,8 +8757,7 @@ test "decl access by string" { {#header_close#} {#header_open|@fieldParentPtr#} -
{#syntax#}@fieldParentPtr(comptime ParentType: type, comptime field_name: []const u8,
-    field_ptr: *T) *ParentType{#endsyntax#}
+
{#syntax#}@fieldParentPtr(comptime field_name: []const u8, field_ptr: *T) anytype{#endsyntax#}

Given a pointer to a field, returns the base pointer of a struct.

-- cgit v1.2.3