crust/main.c

25 lines
556 B
C
Raw Normal View History

2021-11-04 21:15:22 -05:00
#include "rust.h"
fn(main(), int) {
let_mut(a, int) = 7;
2021-11-04 21:15:22 -05:00
a += 1;
print("Hello, World!\n", a);
2021-11-04 21:15:22 -05:00
Ok();
}
2021-11-04 22:58:40 -05:00
typedef const char *ErrString;
typedef void *MemHandle;
Result_impl(MemHandle, ErrString)
Result_unwrap_impl(MemHandle, ErrString)
fn (gimmy_memory(size_t n_bytes), Result(MemHandle, ErrString)){
Result(MemHandle, ErrString) possible =
{.is_valid = true, .data = malloc(n_bytes)};
if (!possible.data)
{
possible.is_valid = false;
possible.err = "memory allocation failure";
}
return possible;
}