Created
January 17, 2024 17:05
-
-
Save ggiraldez/e3709def6c26e7585d12002fc8a0a216 to your computer and use it in GitHub Desktop.
Newly supported Noir printable types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use dep::std; | |
struct Foo { | |
x: u32, | |
y: u32, | |
} | |
// use unconstrained to force Brillig output; some examples don't work with ACIR output | |
unconstrained fn main() { | |
// these are separators and act as sentinels to check that inputs are consumed correctly | |
let x = 48059; | |
let y = 61166; | |
// tuples | |
let a = (1,2,3); | |
std::println(a); | |
std::println(f"{x} # a = {a} # {y}"); | |
std::println(f"{a} == {a}"); | |
std::println(""); | |
// nested tuples | |
let mut b = (a,4,5,6); | |
std::println(b); | |
std::println(f"{x} # b = {b} # {y}"); | |
std::println(f"{b} == {b}"); | |
std::println(""); | |
// mutable references | |
// This doesn't work with ACIR output | |
let mut c = &mut b; | |
std::println(c); | |
std::println(f"{x} # c = {c} # {y}"); | |
std::println(""); | |
// lambdas | |
let d = |x| x+1; | |
std::println(d); | |
std::println(f"{x} # d = {d} # {y}"); | |
std::println(""); | |
// closured lambdas | |
let e = 1; | |
let f = |x| e+x; | |
std::println(f); | |
std::println(f"{x} # f = {f} # {y}"); | |
std::println(""); | |
// arrays | |
let g = [1,2,3]; | |
std::println(g); | |
std::println(f"{x} # g = {g} # {y}"); | |
std::println(f"{g} == {g}"); | |
std::println(""); | |
// structs | |
let f1 = Foo { x: 555, y: 666 }; | |
std::println(f"{f1} == {f1}"); | |
std::println(""); | |
// vectors | |
// This doesn't work with ACIR output | |
let mut h: Vec<Field> = Vec::new(); | |
h.push(1); | |
h.push(2); | |
std::println(h); | |
std::println(f"{x} # h = {h} # {y}"); | |
std::println(""); | |
// slices | |
// This doesn't work with ACIR output | |
let j = h.slice; | |
std::println(j); | |
std::println(f"{x} # j = {j} # {y}"); | |
std::println(f"{j} == {j}"); | |
std::println(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment