速查 / 與 C / Rust 對照

與 C / Rust 對照

語法對照表

變量let x = 1;int x = 1;let mut x = 1;
函數fn f(a: i64) -> i64long f(long a)fn f(a: i64) -> i64
結構體struct S { x: i64 }struct S { long x; }struct S { x: i64 }
列舉帶數據enum E { A(i64), B }需手動 tag + unionenum E { A(i64), B }
匹配match v { ... }switch(僅整數)match v { ... }
字串str(NUL 結尾)char*String / &str
泛型fn f<T>(x: T)宏 / void*fn f<T>(x: T)
借用&x / &mut x指針&x / &mut x
錯誤處理Option / Result + matcherrno / 返回值Result

定位差異

記憶體安全所有權 + 借用檢查手動所有權 + 借用檢查
上手類 C、類型推斷、秒級編譯需要手動管理一切學習曲線陡
記憶體模型所有權 + Arena 雙套手動 malloc/free所有權
與 Python 互操作一行 --pyext 導出手寫擴展pyo3
編譯產物獨立小 EXE / .pyd / .soexe / .soexe / .so

一句話

Aero 取 Rust 的記憶體安全理念(所有權 + 借用檢查)和 C 的上手難度(類 C 語法、無複雜 trait 系統),再加一條 C/Rust 都沒有的捷徑:一行命令導出 Python 模塊。

Aero 文档 · 基于 Aero 1.2.0 文档整理 · MIT
SereinTeam