rust: Make OwningDirstateMap generic and move it into hg-core
This will enable using it in rhg too. The `OwningDirstateMap::new_empty` constructor is generic and accepts a value of any type that gives acces to a bytes buffer. That buffer must stay valid as long as the value hasn’t been dropped, and must keep its memory address even if the value is moved. The `StableDeref` marker trait encodes those constraints. Previously no trait was needed because the value was always of type `PyBytes` which we know satisfies those constraints. The buffer type is ereased in the struct itself through boxing and dynamic dispatch, in order to simplify other signatures that mention `OwningDirstateMap`. Differential Revision: https://phab.mercurial-scm.org/D11396
Showing
- rust/Cargo.lock 10 additions, 0 deletionsrust/Cargo.lock
- rust/hg-core/Cargo.toml 1 addition, 0 deletionsrust/hg-core/Cargo.toml
- rust/hg-core/src/dirstate_tree.rs 2 additions, 0 deletionsrust/hg-core/src/dirstate_tree.rs
- rust/hg-core/src/dirstate_tree/owning.rs 28 additions, 40 deletionsrust/hg-core/src/dirstate_tree/owning.rs
- rust/hg-core/src/dirstate_tree/owning_dispatch.rs 15 additions, 15 deletionsrust/hg-core/src/dirstate_tree/owning_dispatch.rs
- rust/hg-cpython/Cargo.toml 1 addition, 0 deletionsrust/hg-cpython/Cargo.toml
- rust/hg-cpython/src/dirstate.rs 0 additions, 2 deletionsrust/hg-cpython/src/dirstate.rs
- rust/hg-cpython/src/dirstate/dirstate_map.rs 15 additions, 5 deletionsrust/hg-cpython/src/dirstate/dirstate_map.rs
- rust/hg-cpython/src/pybytes_deref.rs 3 additions, 0 deletionsrust/hg-cpython/src/pybytes_deref.rs
Loading
Please register or sign in to comment