Why use `@import("root")`?

As a library, you might want to access your users root module (main.zig) to look at its declarations, e.g std_options:

const root = @import("root");

/// Stdlib-wide options that can be overridden by the root file.
pub const options: Options = if (@hasDecl(root, "std_options")) root.std_options else .{};
5 Likes