diff --git a/docs/docs/noir/concepts/comptime.md b/docs/docs/noir/concepts/comptime.md index 28cf35c7ca7..13dbe6ba4e5 100644 --- a/docs/docs/noir/concepts/comptime.md +++ b/docs/docs/noir/concepts/comptime.md @@ -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