Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/docs/noir/concepts/comptime.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,19 @@ For cases like this there is `$crate` which when used in a quote will always res
So the library author can instead quote `$crate::foo::my_function()` and have it work in all cases as long as
`foo` and `my_function` are both publicly visible.

```rust
/// We want to access this function within the quoted code below
/// and we want it to work in external crates.
pub fn double(x: Field) -> Field { x * 2 }

comptime fn double_twice(code: Quoted) -> Quoted {
quote {
// `$crate` is a stand-in for the current crate
$crate::double($crate::double($code))
}
}
```

---

## Attributes
Expand Down
Loading