1.2 KiB
1.2 KiB
Translation Glossary: C++ → Rust
This glossary defines consistent mappings from MABE2 / Empirical idioms to MabeLabRS Rust code. It should be updated as the port progresses.
Memory / Pointers
std::unique_ptr<T>→Box<T>std::shared_ptr<T>→Arc<T>(multi-thread safe), orRc<T>(single-thread)std::weak_ptr<T>→Weak<T>(Arc/Rc)- raw pointer (owning) →
Box<T> - raw pointer (borrowed) →
&Tor&mut T
Optional / Variants
std::optional<T>→Option<T>std::variant<A,B>→enum { A(A), B(B) }
Containers
std::vector<T>→Vec<T>std::map<K,V>→BTreeMap<K,V>(ordered, deterministic)std::unordered_map<K,V>→HashMap<K,V>orIndexMap<K,V>(deterministic)std::set<T>→BTreeSet<T>
Interfaces / Inheritance
- C++ abstract base class → Rust
trait - C++ pure virtual function →
fn ...;in trait - C++ virtual function → default method in trait
Errors
- Error codes / exceptions →
Result<T, E>withthiserrorderive
Utilities
- C++ RNG (emp::Random) →
rand_chacha::ChaCha8Rngseeded via manifest - Empirical Config →
serde+toml/json - Empirical Signals/Actions → strongly typed Rust event bus (observer pattern)