CRust
CRust is a satirical programming paradigm that blends elements of C and Rust, designed to address what its creator perceives as Rust's verbosity and complexity. Developed by Tsoding, CRust is described as "Rust that is actually Fun" in its original GitHub repository with a goal to "make programming in Rust fun".
The paradigm consists of a straightforward set of rules and is compatible exclusively with Rust edition 2021. CRust is intended primarily as a humorous project and is not recommended for use in production environments.
Rules
CRust is a paradigm consisting of 7 rules:
- Every function is
unsafe. - No references, only pointers.
- No cargo, build with
rustcdirectly. - No
std, but libc is allowed. - Only [Rust] Edition 2021.
- All user
structs andenums[:]#[derive(Clone, Copy)]. - Everything is
pubby default.
These rules are defined in its GitHub repository at https://github.com/tsoding/crust and currently this paradigm is used in Tsoding's B language compiler.
Licensing
CRust is licensed under the MIT license by Tsoding.
Examples
Hello World
// Compile with: rustc hello.rs -C panic=abort --edition=2021
#![no_std]
#![no_main]
use core::panic::PanicInfo;
#[panic_handler]
pub unsafe fn panic(_info: &PanicInfo) -> ! {
loop {}
}
#[link(name = "c")]
unsafe extern "C" {
fn puts(s: *const u8) -> i32;
}
#[no_mangle]
pub unsafe extern "C" fn main(_argc: i32, _argv: *mut *mut u8) -> i32 {
let msg: *const u8 = b"Hello, World!\0".as_ptr();
puts(msg);
return 0;
}