@@ -4952,34 +4952,25 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
4952
4952
{#header_close#}
4953
4953
4954
4954
{#header_open|@import#}
4955
- <pre>{#syntax#}@import(comptime path: []const u8) type{#endsyntax#}</pre>
4956
- <p>
4957
- This function finds a zig file corresponding to {#syntax#}path{#endsyntax#} and adds it to the build,
4958
- if it is not already added.
4959
- </p>
4960
- <p>
4961
- Zig source files are implicitly structs, with a name equal to the file's basename with the extension
4962
- truncated. {#syntax#}@import{#endsyntax#} returns the struct type corresponding to the file.
4963
- </p>
4964
- <p>
4965
- Declarations which have the {#syntax#}pub{#endsyntax#} keyword may be referenced from a different
4966
- source file than the one they are declared in.
4967
- </p>
4968
- <p>
4969
- {#syntax#}path{#endsyntax#} can be a relative path or it can be the name of a package.
4970
- If it is a relative path, it is relative to the file that contains the {#syntax#}@import{#endsyntax#}
4971
- function call.
4972
- </p>
4973
- <p>
4974
- The following packages are always available:
4975
- </p>
4955
+ <pre>{#syntax#}@import(comptime target: []const u8) anytype{#endsyntax#}</pre>
4956
+ <p>Imports the file at {#syntax#}target{#endsyntax#}, adding it to the compilation if it is not already
4957
+ added. {#syntax#}target{#endsyntax#} is either a relative path to another file from the file containing
4958
+ the {#syntax#}@import{#endsyntax#} call, or it is the name of a {#link|module|Compilation Model#}, with
4959
+ the import referring to the root source file of that module. Either way, the file path must end in
4960
+ either <code>.zig</code> (for a Zig source file) or <code>.zon</code> (for a ZON data file).</p>
4961
+ <p>If {#syntax#}target{#endsyntax#} refers to a Zig source file, then {#syntax#}@import{#endsyntax#} returns
4962
+ that file's {#link|corresponding struct type|Source File Structs#}, essentially as if the builtin call was
4963
+ replaced by {#syntax#}struct { FILE_CONTENTS }{#endsyntax#}. The return type is {#syntax#}type{#endsyntax#}.</p>
4964
+ <p>If {#syntax#}target{#endsyntax#} refers to a ZON file, then {#syntax#}@import{#endsyntax#} returns the value
4965
+ of the literal in the file. If there is an inferred {#link|result type|Result Types#}, then the return type
4966
+ is that type, and the ZON literal is interpreted as that type ({#link|Result Types#} are propagated through
4967
+ the ZON expression). Otherwise, the return type is the type of the equivalent Zig expression, essentially as
4968
+ if the builtin call was replaced by the ZON file contents.</p>
4969
+ <p>The following modules are always available for import:</p>
4976
4970
<ul>
4977
4971
<li>{#syntax#}@import("std"){#endsyntax#} - Zig Standard Library</li>
4978
- <li>{#syntax#}@import("builtin"){#endsyntax#} - Target-specific information
4979
- The command <code>zig build-exe --show-builtin</code> outputs the source to stdout for reference.
4980
- </li>
4981
- <li>{#syntax#}@import("root"){#endsyntax#} - Root source file
4982
- This is usually <code>src/main.zig</code> but depends on what file is built.
4972
+ <li>{#syntax#}@import("builtin"){#endsyntax#} - Target-specific information. The command <code>zig build-exe --show-builtin</code> outputs the source to stdout for reference.</li>
4973
+ <li>{#syntax#}@import("root"){#endsyntax#} - Alias for the root module. In typical project structures, this means it refers back to <code>src/main.zig</code>.
4983
4974
</li>
4984
4975
</ul>
4985
4976
{#see_also|Compile Variables|@embedFile#}
0 commit comments