@@ -1988,7 +1988,7 @@ test "null terminated array" {
1988
1988
<li>Supports slice syntax: {#syntax#}ptr[start..end]{#endsyntax#}</li>
1989
1989
<li>Supports pointer arithmetic: {#syntax#}ptr + x{#endsyntax#}, {#syntax#}ptr - x{#endsyntax#}</li>
1990
1990
<li>{#syntax#}T{#endsyntax#} must have a known size, which means that it cannot be
1991
- {#syntax#}c_void{#endsyntax#} or any other {#link|opaque type|Opaque Types #}.</li>
1991
+ {#syntax#}c_void{#endsyntax#} or any other {#link|opaque type|opaque #}.</li>
1992
1992
</ul>
1993
1993
</li>
1994
1994
</ul>
@@ -5545,7 +5545,7 @@ test "turn HashMap into a set with void" {
5545
5545
</p>
5546
5546
<p>
5547
5547
{#syntax#}void{#endsyntax#} is distinct from {#syntax#}c_void{#endsyntax#}, which is defined like this:
5548
- {#syntax#}pub const c_void = @Type(.Opaque) ;{#endsyntax#}.
5548
+ {#syntax#}pub const c_void = opaque {} ;{#endsyntax#}.
5549
5549
{#syntax#}void{#endsyntax#} has a known size of 0 bytes, and {#syntax#}c_void{#endsyntax#} has an unknown, but non-zero, size.
5550
5550
</p>
5551
5551
<p>
@@ -8471,7 +8471,7 @@ test "integer truncation" {
8471
8471
<li>{#link|Error Set Type#}</li>
8472
8472
<li>{#link|Error Union Type#}</li>
8473
8473
<li>{#link|Vectors#}</li>
8474
- <li>{#link|Opaque Types #}</li>
8474
+ <li>{#link|opaque #}</li>
8475
8475
<li>{#link|@Frame#}</li>
8476
8476
<li>{#syntax#}anyframe{#endsyntax#}</li>
8477
8477
<li>{#link|struct#}</li>
@@ -8547,17 +8547,18 @@ fn foo(comptime T: type, ptr: *T) T {
8547
8547
{#header_close#}
8548
8548
{#header_close#}
8549
8549
8550
- {#header_open|Opaque Types #}
8550
+ {#header_open|opaque #}
8551
8551
<p>
8552
- {#syntax#}@Type(.Opaque){#endsyntax#} creates a new type with an unknown (but non-zero) size and alignment.
8552
+ {#syntax#}opaque {}{#endsyntax#} declares a new type with an unknown (but non-zero) size and alignment.
8553
+ It can have declarations like structs, unions, or enums.
8553
8554
</p>
8554
8555
<p>
8555
8556
This is typically used for type safety when interacting with C code that does not expose struct details.
8556
8557
Example:
8557
8558
</p>
8558
8559
{#code_begin|test_err|expected type '*Derp', found '*Wat'#}
8559
- const Derp = @Type(.Opaque) ;
8560
- const Wat = @Type(.Opaque) ;
8560
+ const Derp = opaque {} ;
8561
+ const Wat = opaque {} ;
8561
8562
8562
8563
extern fn bar(d: *Derp) void;
8563
8564
fn foo(w: *Wat) callconv(.C) void {
0 commit comments