3 unstable releases

0.1.1 Feb 24, 2019
0.1.0 Dec 10, 2018
0.0.0 Sep 9, 2017

#2298 in Rust patterns

MIT/Apache

11KB
246 lines

smart - dynamically dispatched smart pointers

This library lets you construct a smart pointer dynamically from one of our different pointers which implement shared ownership. It has both a threadsafe (SyncPointer) and non-threadsafe (SharedPointer) construct.

This is useful for when you need an API to dynamically be one of multiple different pointer types. This has a slight overhead (virtual calls), so you should not use this unless you know that's what you want.


lib.rs:

Dynamic smart pointers for abstracting over different ownership models.

This library allows you to dynamically abstract over three different kinds of "shared ownership" in Rust: Rc, Arc and &'static. The two pointers defined in this crate can be constructed from multiple different kinds of shared ownership pointers, dynamically dispatching their Clone and Drop implementations.

A SharedPointer can be constructed from any of the three pointer types, but does not implement Send or Sync. A SyncPointer can only be constructed from Arc or &'static, and is threadsafe. Converting a SharedPointer to a SyncPointer is allowed, but panics if the SharedPointer was constructed from an Rc.

No runtime deps

Features