36 lines
1.2 KiB
Markdown
36 lines
1.2 KiB
Markdown
# 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), or `Rc<T>` (single-thread)
|
|
- `std::weak_ptr<T>` → `Weak<T>` (Arc/Rc)
|
|
- raw pointer (owning) → `Box<T>`
|
|
- raw pointer (borrowed) → `&T` or `&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>` or `IndexMap<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>` with `thiserror` derive
|
|
|
|
## Utilities
|
|
- C++ RNG (emp::Random) → `rand_chacha::ChaCha8Rng` seeded via manifest
|
|
- Empirical Config → `serde` + `toml/json`
|
|
- Empirical Signals/Actions → strongly typed Rust event bus (observer pattern)
|
|
|