# Is there something like Rust's cargo expand for Zig's comptime

**URL:** <https://ziggit.dev/t/is-there-something-like-rusts-cargo-expand-for-zigs-comptime/5035>\
**Category:** Explain\
**Tags:** comptime\
**Created:** [July 8, 2024, 3:41pm UTC](https://ziggit.dev/t/is-there-something-like-rusts-cargo-expand-for-zigs-comptime/5035 "2024-07-08T15:41:10Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![mlugg](https://ziggit.dev/user_avatar/ziggit.dev/mlugg/32/437_2.png) [@mlugg](https://ziggit.dev/u/mlugg)\
**Post date:** [July 8, 2024, 4:02pm UTC](https://ziggit.dev/t/is-there-something-like-rusts-cargo-expand-for-zigs-comptime/5035/5 "2024-07-08T16:02:53Z")

</div>

The comment above is fairly accurate. A feature like this doesn’t really work for Zig, because comptime isn’t acting on the AST, so we can’t really recover Zig code from it. Implementation-wise, comptime is essentially an interpreter for Zig code. When executing at runtime, it’s essentially an interpreter which emits runtime instructions instead of actually doing the computation. In your specific example of `inline for`, the loop condition is interpreted at comptime, so the compiler itself is looping 4 times (over each of those types); and the body of the loop is being “interpreted” in a runtime sense, so it emits runtime code for each iteration rather than actually trying to comptime-eval `std.debug.print`.

To try and understand the execution of comptime code, note the existence of `@compileLog`, which allows you to print arbitrary values at comptime. Try replacing your `std.debug.print` call with `@compileLog(@typeInfo(T).Int.bits)` for example.

---

_[View the full topic](https://ziggit.dev/t/is-there-something-like-rusts-cargo-expand-for-zigs-comptime/5035)._
