aboutsummaryrefslogtreecommitdiff
path: root/syn/examples/trace-var/example/src
diff options
context:
space:
mode:
Diffstat (limited to 'syn/examples/trace-var/example/src')
-rw-r--r--syn/examples/trace-var/example/src/main.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/syn/examples/trace-var/example/src/main.rs b/syn/examples/trace-var/example/src/main.rs
new file mode 100644
index 0000000..da2c10b
--- /dev/null
+++ b/syn/examples/trace-var/example/src/main.rs
@@ -0,0 +1,15 @@
+use trace_var::trace_var;
+
+fn main() {
+ println!("{}", factorial(8));
+}
+
+#[trace_var(p, n)]
+fn factorial(mut n: u64) -> u64 {
+ let mut p = 1;
+ while n > 1 {
+ p *= n;
+ n -= 1;
+ }
+ p
+}