2021-11-04 21:15:22 -05:00
|
|
|
#include "rust.h"
|
|
|
|
|
2021-11-04 21:59:38 -05:00
|
|
|
fn(main(), int) {
|
|
|
|
let_mut(a, int) = 7;
|
2021-11-04 21:15:22 -05:00
|
|
|
a += 1;
|
2021-11-04 21:59:38 -05:00
|
|
|
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;
|
|
|
|
}
|