pub struct Mrc<T: ?Sized + 'static> { /* private fields */ }

Implementations

Creates a Mrc<T> from a value that borrows T.

This is just implemented as Mrc::map(Mrc::new(c), |c| c.borrow()).

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 Mrc that refers to the data returned by the closure.

This only changes what data this particular Mrc refers to. It does not introduce mutability - any Mrc<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 Mrc<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 Mrc<T> , returning the new value on success and the old value otherwise.

This is simply a fallible version of Mrc::map , and generally has all the same properties.

Maps the value that the Mrc 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 Mrc from an Rc that shares ownership of the Rc’s data.

Like Mrc::new, this method requires T: Sized + 'static. If you have an Rc<T> where T: ?Sized, then you can create an Mrc<T> via Mrc::from_borrow.

As long as the returned Mrc is alive, the strong count of the Rc will be at least one. This is also the case if any Mrc’s derived from the return value via Clone and Mrc::map are alive. The strong count of the input Rc could be observed by another Rc 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 Mrc that provides shared ownership of the T.

This method, like all ways of creating an Mrc, has a 'static bound that is not found on the corresponding Rc method. That requirement is fundamentally necessary for the soundness of this type and cannot be circumvented.

Trait Implementations

Performs the conversion.

Immutably borrows from an owned value. Read more

Creates a new Mrc<T> sharing ownership of the same data.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Creates a value from an iterator. Read more

Feeds this value into the given Hasher. Read more

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

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Formats the value using the given formatter.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. 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.