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

Implementations

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

This is just implemented as Marc::map(Marc::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 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

Performs the conversion.

Immutably borrows from an owned value. Read more

Creates a new Marc<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.