pub struct Shared<T> { /* private fields */ }
Expand description
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.
Performs copy-assignment from
source
.
Read more
Formats the value using the given formatter.
Read more
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.
Deserialize this value from the given Serde deserializer.
Read more
This method tests for
self
and
other
values to be equal, and is used
by
==
.
Read more
This method tests for
!=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
Read more
Serialize this value into the given Serde serializer.
Read more
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more
Uses borrowed data to replace owned data, usually by cloning.
Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.