|
638 | 638 | {#syntax#}i7{#endsyntax#} refers to a signed 7-bit integer. The maximum allowed bit-width of an |
639 | 639 | integer type is {#syntax#}65535{#endsyntax#}. |
640 | 640 | </p> |
641 | | - {#see_also|Integers|Floats|void|Errors|@Type#} |
| 641 | + {#see_also|Integers|Floats|void|Errors|@Int#} |
642 | 642 | {#header_close#} |
643 | 643 | {#header_open|Primitive Values#} |
644 | 644 | <div class="table-wrapper"> |
@@ -3723,9 +3723,9 @@ void do_a_thing(struct Foo *foo) { |
3723 | 3723 | <td>{#syntax#}x{#endsyntax#} is a {#syntax#}@FieldType(T, "a"){#endsyntax#}</td> |
3724 | 3724 | </tr> |
3725 | 3725 | <tr> |
3726 | | - <th scope="row">{#syntax#}@Type(x){#endsyntax#}</th> |
| 3726 | + <th scope="row">{#syntax#}@Int(x, y){#endsyntax#}</th> |
3727 | 3727 | <td>-</td> |
3728 | | - <td>{#syntax#}x{#endsyntax#} is a {#syntax#}std.builtin.Type{#endsyntax#}</td> |
| 3728 | + <td>{#syntax#}x{#endsyntax#} is a {#syntax#}std.builtin.Signedness{#endsyntax#}, {#syntax#}y{#endsyntax#} is a {#syntax#}u16{#endsyntax#}</td> |
3729 | 3729 | </tr> |
3730 | 3730 | <tr> |
3731 | 3731 | <th scope="row">{#syntax#}@typeInfo(x){#endsyntax#}</th> |
@@ -3839,9 +3839,9 @@ void do_a_thing(struct Foo *foo) { |
3839 | 3839 | <td>{#syntax#}x{#endsyntax#} has no result location (typed initializers do not propagate result locations)</td> |
3840 | 3840 | </tr> |
3841 | 3841 | <tr> |
3842 | | - <th scope="row">{#syntax#}@Type(x){#endsyntax#}</th> |
3843 | | - <td>{#syntax#}ptr{#endsyntax#}</td> |
3844 | | - <td>{#syntax#}x{#endsyntax#} has no result location</td> |
| 3842 | + <th scope="row">{#syntax#}@Int(x, y){#endsyntax#}</th> |
| 3843 | + <td>-</td> |
| 3844 | + <td>{#syntax#}x{#endsyntax#} and {#syntax#}y{#endsyntax#} do not have result locations</td> |
3845 | 3845 | </tr> |
3846 | 3846 | <tr> |
3847 | 3847 | <th scope="row">{#syntax#}@typeInfo(x){#endsyntax#}</th> |
@@ -5755,41 +5755,75 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val |
5755 | 5755 | </p> |
5756 | 5756 | {#header_close#} |
5757 | 5757 |
|
5758 | | - {#header_open|@Type#} |
5759 | | - <pre>{#syntax#}@Type(comptime info: std.builtin.Type) type{#endsyntax#}</pre> |
5760 | | - <p> |
5761 | | - This function is the inverse of {#link|@typeInfo#}. It reifies type information |
5762 | | - into a {#syntax#}type{#endsyntax#}. |
5763 | | - </p> |
5764 | | - <p> |
5765 | | - It is available for the following types: |
5766 | | - </p> |
5767 | | - <ul> |
5768 | | - <li>{#syntax#}type{#endsyntax#}</li> |
5769 | | - <li>{#syntax#}noreturn{#endsyntax#}</li> |
5770 | | - <li>{#syntax#}void{#endsyntax#}</li> |
5771 | | - <li>{#syntax#}bool{#endsyntax#}</li> |
5772 | | - <li>{#link|Integers#} - The maximum bit count for an integer type is {#syntax#}65535{#endsyntax#}.</li> |
5773 | | - <li>{#link|Floats#}</li> |
5774 | | - <li>{#link|Pointers#}</li> |
5775 | | - <li>{#syntax#}comptime_int{#endsyntax#}</li> |
5776 | | - <li>{#syntax#}comptime_float{#endsyntax#}</li> |
5777 | | - <li>{#syntax#}@TypeOf(undefined){#endsyntax#}</li> |
5778 | | - <li>{#syntax#}@TypeOf(null){#endsyntax#}</li> |
5779 | | - <li>{#link|Arrays#}</li> |
5780 | | - <li>{#link|Optionals#}</li> |
5781 | | - <li>{#link|Error Set Type#}</li> |
5782 | | - <li>{#link|Error Union Type#}</li> |
5783 | | - <li>{#link|Vectors#}</li> |
5784 | | - <li>{#link|opaque#}</li> |
5785 | | - <li>{#syntax#}anyframe{#endsyntax#}</li> |
5786 | | - <li>{#link|struct#}</li> |
5787 | | - <li>{#link|enum#}</li> |
5788 | | - <li>{#link|Enum Literals#}</li> |
5789 | | - <li>{#link|union#}</li> |
5790 | | - <li>{#link|Functions#}</li> |
5791 | | - </ul> |
| 5758 | + {#header_open|@EnumLiteral#} |
| 5759 | + <pre>{#syntax#}@EnumLiteral() type{#endsyntax#}</pre> |
| 5760 | + <p>Returns the comptime-only "enum literal" type. This is the type of uncoerced {#link|Enum Literals#}. Values of this type can coerce to any {#link|enum#} with a matching field.</p> |
| 5761 | + {#header_close#} |
| 5762 | + |
| 5763 | + {#header_open|@Int#} |
| 5764 | + <pre>{#syntax#}@Int(comptime signedness: std.builtin.Signedness, comptime bits: u16) type{#endsyntax#}</pre> |
| 5765 | + <p>Returns an integer type with the given signedness and bit width.</p> |
| 5766 | + <p>For instance, {#syntax#}@Int(.unsigned, 18){#endsyntax#} returns the type {#syntax#}u18{#endsyntax#}.</p> |
5792 | 5767 | {#header_close#} |
| 5768 | + |
| 5769 | + {#header_open|@Tuple#} |
| 5770 | + <pre>{#syntax#}@Tuple(comptime field_types: []const type) type{#endsyntax#}</pre> |
| 5771 | + <p>Returns a {#link|tuple|Tuples#} type with the given field types.</p> |
| 5772 | + {#header_close#} |
| 5773 | + |
| 5774 | + {#header_open|@Pointer#} |
| 5775 | + <pre>{#syntax#}@Pointer( |
| 5776 | + comptime size: std.builtin.Type.Pointer.Size, |
| 5777 | + comptime attrs: std.builtin.Type.Pointer.Attributes, |
| 5778 | + comptime Element: type, |
| 5779 | + comptime sentinel: ?Element, |
| 5780 | +) type{#endsyntax#}</pre> |
| 5781 | + <p>Returns a {#link|pointer|Pointers#} type with the properties specified by the arguments.</p> |
| 5782 | + {#header_close#} |
| 5783 | + |
| 5784 | + {#header_open|@Fn#} |
| 5785 | + <pre>{#syntax#}@Fn( |
| 5786 | + comptime param_types: []const type, |
| 5787 | + comptime param_attrs: *const [param_types.len]std.builtin.Type.Fn.Param.Attributes, |
| 5788 | + comptime ReturnType: type, |
| 5789 | + comptime attrs: std.builtin.Type.Fn.Attributes, |
| 5790 | +) type{#endsyntax#}</pre> |
| 5791 | + <p>Returns a {#link|function|Functions#} type with the properties specified by the arguments.</p> |
| 5792 | + {#header_close#} |
| 5793 | + |
| 5794 | + {#header_open|@Struct#} |
| 5795 | + <pre>{#syntax#}@Struct( |
| 5796 | + comptime layout: std.builtin.Type.ContainerLayout, |
| 5797 | + comptime BackingInt: ?type, |
| 5798 | + comptime field_names: []const []const u8, |
| 5799 | + comptime field_types: *const [field_names.len]type, |
| 5800 | + comptime field_attrs: *const [field_names.len]std.builtin.Type.StructField.Attributes, |
| 5801 | +) type{#endsyntax#}</pre> |
| 5802 | + <p>Returns a {#link|struct#} type with the properties specified by the arguments.</p> |
| 5803 | + {#header_close#} |
| 5804 | + |
| 5805 | + {#header_open|@Union#} |
| 5806 | + <pre>{#syntax#}@Union( |
| 5807 | + comptime layout: std.builtin.Type.ContainerLayout, |
| 5808 | + /// Either the integer tag type, or the integer backing type, depending on `layout`. |
| 5809 | + comptime ArgType: ?type, |
| 5810 | + comptime field_names: []const []const u8, |
| 5811 | + comptime field_types: *const [field_names.len]type, |
| 5812 | + comptime field_attrs: *const [field_names.len]std.builtin.Type.UnionField.Attributes, |
| 5813 | +) type{#endsyntax#}</pre> |
| 5814 | + <p>Returns a {#link|union#} type with the properties specified by the arguments.</p> |
| 5815 | + {#header_close#} |
| 5816 | + |
| 5817 | + {#header_open|@Enum#} |
| 5818 | + <pre>{#syntax#}@Enum( |
| 5819 | + comptime TagInt: type, |
| 5820 | + comptime mode: std.builtin.Type.Enum.Mode, |
| 5821 | + comptime field_names: []const []const u8, |
| 5822 | + comptime field_values: *const [field_names.len]TagInt, |
| 5823 | +) type{#endsyntax#}</pre> |
| 5824 | + <p>Returns an {#link|enum#} type with the properties specified by the arguments.</p> |
| 5825 | + {#header_close#} |
| 5826 | + |
5793 | 5827 | {#header_open|@typeInfo#} |
5794 | 5828 | <pre>{#syntax#}@typeInfo(comptime T: type) std.builtin.Type{#endsyntax#}</pre> |
5795 | 5829 | <p> |
|
0 commit comments