decy-codegen 2.2.0

Rust code generation from HIR with minimal unsafe blocks
Documentation

Rust code generation from HIR with minimal unsafe blocks.

Generates idiomatic Rust code with <5 unsafe blocks per 1000 LOC.

Examples

use decy_codegen::CodeGenerator;
use decy_hir::{HirFunction, HirType, HirParameter};

let func = HirFunction::new(
    "add".to_string(),
    HirType::Int,
    vec![
        HirParameter::new("a".to_string(), HirType::Int),
        HirParameter::new("b".to_string(), HirType::Int),
    ],
);

let codegen = CodeGenerator::new();
let code = codegen.generate_function(&func);

assert!(code.contains("fn add"));
assert!(code.contains("a: i32"));
assert!(code.contains("b: i32"));