Struct fungi_lang::shared::Shared[][src]

pub struct Shared<T> { /* fields omitted */ }

A shared instance of T that serializes once, not once per reference.

Unlike a "bare" Rc, a Shared enjoys the practical property that, when a structure holding multiple (shared) instances of T is serialized, this serialized output holds only one occurrence of a T's serialized representation; the other occurrences merely consist of the T's unique identifier (the serialization of an Id, single machine word on modern machines).

In particular, a shared T has a unique ID permitting table-based indirection, via temporary storage used by serialization and serialization logic; by contrast, a bare Rc lacks this indirection, and thus, it lacks a compact serialized representation for structures with abundant sharing. Generally, abundant sharing via many shared Rc<_>s leads to exponential "blow up" in terms of serialized space and time.

Methods

impl<T: Hash + 'static> Shared<T>
[src]

Trait Implementations

impl<T: Clone> Clone for Shared<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: PartialEq + 'static> PartialEq for Shared<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T: PartialEq + 'static> Eq for Shared<T>
[src]

impl<T: 'static + Hash> Hash for Shared<T>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: Debug> Debug for Shared<T>
[src]

Formats the value using the given formatter. Read more

impl<T> Deref for Shared<T>
[src]

We may deference a (deserialized) Shared just like an Rc; below, rely on the invariant that all deserialized Shared's consist of an Rc (along with a unique ID).

The resulting type after dereferencing.

Dereferences the value.

impl<T: Serialize + Hash + 'static> Serialize for Shared<T>
[src]

Serialize this value into the given Serde serializer. Read more

impl<'de, T: Deserialize<'de> + Hash + 'static> Deserialize<'de> for Shared<T>
[src]

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations

impl<T> !Send for Shared<T>

impl<T> !Sync for Shared<T>