diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-03-31 01:47:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-31 01:47:23 -0700 |
| commit | a6ed3e6d29b0e2cedfc20048b014cff4e0ae4eaa (patch) | |
| tree | 11b933e936d64f00a7a820a21afe2633b34d5941 /doc/langref.html.in | |
| parent | aff71c6132fd17c6fa455a6e7b9f53567e3e55b2 (diff) | |
| parent | e5ba70bb5c176ba553a5458f89004b44da2b93d6 (diff) | |
| download | zig-a6ed3e6d29b0e2cedfc20048b014cff4e0ae4eaa.tar.gz zig-a6ed3e6d29b0e2cedfc20048b014cff4e0ae4eaa.zip | |
Merge pull request #19470 from jacobly0/field-parent-ptr
Rework `@fieldParentPtr` to use RLS
Diffstat (limited to 'doc/langref.html.in')
| -rw-r--r-- | doc/langref.html.in | 5 |
1 files changed, 2 insertions, 3 deletions
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#} - <pre>{#syntax#}@fieldParentPtr(comptime ParentType: type, comptime field_name: []const u8, - field_ptr: *T) *ParentType{#endsyntax#}</pre> + <pre>{#syntax#}@fieldParentPtr(comptime field_name: []const u8, field_ptr: *T) anytype{#endsyntax#}</pre> <p> Given a pointer to a field, returns the base pointer of a struct. </p> |
