• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H03-May-2022-19056

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D13-Jul-202074 65

.gitignoreH A D06-Mar-201718 32

Cargo.tomlH A D13-Jul-20201.1 KiB2825

Cargo.toml.orig-cargoH A D13-Jul-2020596 1816

LICENSE-APACHEH A D06-Mar-201710.6 KiB202169

LICENSE-MITH A D08-Mar-20171 KiB2522

README.mdH A D09-Jun-20181.5 KiB2418

README.md

1This crate defines an unsafe marker trait, StableDeref, for container types which deref to a fixed address which is valid even when the containing type is moved. For example, Box, Vec, Rc, Arc and String implement this trait. Additionally, it defines CloneStableDeref for types like Rc where clones deref to the same address.
2
3It is intended to be used by crates such as [owning_ref](https://crates.io/crates/owning_ref) and [rental](https://crates.io/crates/rental), as well as library authors who wish to make their code interoperable with such crates. For example, if you write a custom Vec type, you can implement StableDeref, and then users will be able to use your custom Vec type together with owning_ref and rental.
4
5no_std support can be enabled by disabling default features (specifically "std"). In this case, the trait will not be implemented for the std types mentioned above, but you can still use it for your own types.
6
7Enable the "alloc" feature (with default-features disabled) to have this trait be implemented for the above types from the built-in `alloc` crate, specifically
8* `alloc::boxed::Box`
9* `alloc::vec::Vec`
10* `alloc::rc::Rc`
11* `alloc::arc::Arc`
12* `alloc::string::String`
13
14For example, this crate can be built with alloc support via the following command:
15`cargo build --no-default-features --features alloc`
16
17Or added as a `Cargo.toml` dependency as follows:
18```
19[dependencies.stable_deref_trait]
20version = "<version>"
21default-features = false
22features = [ "alloc" ]
23```
24