Struct mappable_rc::Marc
source · [−]pub struct Marc<T: ?Sized + 'static> { /* private fields */ }Implementations
Returns a read-only pointer to the referred to data.
The pointer is valid for as long as this value is alive.
Maps the value to a new
Marc
that refers to the data returned by the closure.
This only changes what data this particular
Marc
refers to. It does not introduce mutability - any
Marc<T>s
you’ve cloned from this one in the past still point to the same thing. Of course, if
you clone the value returned by this function, then the resulting
Marc<U>s
will also point to the mapped value.
This does not cause the T to be dropped early. Even if the &U refers to only a
part of the &T, no part of the T is dropped until all references to or into the
T are gone, at which point the entire T is dropped at once.
Attempts to map the
Marc<T>
, returning the new value on success and the old value otherwise.
This is simply a fallible version of
Marc::map
, and generally has all the same properties.
Maps the value that the
Marc
refers to, without taking ownership.
This is equivalent to cloning, mapping, and then writing to self, except that it
is slightly more efficient because it avoids the clone.
self is left unchanged if f panics.
Creates a new Marc from an Arc that shares ownership of the Arc’s data.
Like Marc::new, this method requires T: Send + Sized + 'static. If you have an
Arc<T> where T: ?Sized, then you can create an Marc<T> via Marc::from_borrow.
As long as the returned Marc is alive, the strong count of the Arc will be at least one.
This is also the case if any Marc’s derived from the return value via Clone and
Marc::map are alive. The strong count of the input Arc could be observed by another
Arc also sharing ownership of the data. It is not specified whether clones of the return
value will be reflected in that strong count.
This function is essentially free to call. After inlining, it will consist of one to two pointer copies.
Creates a new Marc that provides shared ownership of the T.
This method, like all ways of creating an Marc, has a Send + 'static bound that is not
found on the corresponding Arc method. You can avoid the Send requirement by using
Mrc::from_borrow to create an Mrc instead. The 'static requirement is
fundamentally necessary for the soundness of this type and cannot be circumvented.
Trait Implementations
Creates a new Marc<T> sharing ownership of the same data.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
Blanket Implementations
Mutably borrows from an owned value. Read more