From 65688204070722d0cb8ece765c2b41e28d07d645 Mon Sep 17 00:00:00 2001 From: Able Date: Thu, 4 Nov 2021 21:59:38 -0500 Subject: [PATCH] betseg helped imnporeove let and let_mut --- main.c | 7 +++---- rust.h | 15 ++++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index b19f0b9..f1f3577 100644 --- a/main.c +++ b/main.c @@ -1,9 +1,8 @@ -#include #include "rust.h" -fn main() { - let_mut_int a = 7; - print("Hello, World!\n"); +fn(main(), int) { + let_mut(a, int) = 7; a += 1; + print("Hello, World!\n", a); Ok(); } diff --git a/rust.h b/rust.h index a9d064d..a3aa732 100644 --- a/rust.h +++ b/rust.h @@ -1,17 +1,14 @@ #include +#include -#define fn int -#define let_int const int -#define let_float const float -#define let_bool const bool -#define let_char const char -#define let_mut_int int -#define let_mut_float float -#define let_mut_bool bool -#define let_mut_char char +#define fn(decl, type) type decl +#define let(decl, type) const type decl +#define let_mut(decl, type) type decl #define print printf #define loop while(true) #define Ok(); return 0 #define Err(); return 1 + +#define enum union