Crates.io | tiptoe |
lib.rs | tiptoe |
version | 0.0.2 |
source | src |
created_at | 2021-11-08 16:28:22.384202 |
updated_at | 2021-11-12 16:03:29.679373 |
description | An easy-to-support intrusively reference-counting smart pointer. |
homepage | https://github.com/Tamschi/tiptoe/tree/v0.0.2 |
repository | https://github.com/Tamschi/tiptoe |
max_upload_size | |
id | 478541 |
size | 60,072 |
An easy-to-support intrusively reference-counting smart pointer.
Please use cargo-edit to always add the latest version of this library:
cargo add tiptoe --features sync
"sync"
Enables the [Arc
] type, which requires AtomicUsize
.
use pin_project::pin_project;
use tiptoe::{IntrusivelyCountable, TipToe};
// All attributes optional.
#[pin_project]
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct A {
#[pin]
ref_counter: TipToe,
}
unsafe impl IntrusivelyCountable for A {
type RefCounter = TipToe;
fn ref_counter(&self) -> &Self::RefCounter {
&self.ref_counter
}
}
fn main() {
#[cfg(feature = "sync")]
{
use tiptoe::Arc;
let arc = Arc::new(A::default());
let inner_ref: &A = &arc;
let another_arc = unsafe {
Arc::borrow_from_inner_ref(&inner_ref)
}.clone();
}
}
This library is currently only implemented about as far as I need it for rhizome.
Please have a look at the issues if you'd like to help out.
Notable current omissions: Rc
, Weak
, and most optimisation that doesn't affect the API.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
See CONTRIBUTING for more information.
tiptoe
strictly follows Semantic Versioning 2.0.0 with the following exceptions:
This includes the Rust version requirement specified above.
Earlier Rust versions may be compatible, but this can change with minor or patch releases.
Which versions are affected by features and patches can be determined from the respective headings in CHANGELOG.md.
Note that dependencies of this crate may have a more lenient MSRV policy!
Please use cargo +nightly update -Z minimal-versions
in your automation if you don't generate Cargo.lock manually (or as necessary) and require support for a compiler older than current stable.