pub struct RMBA<'a, T: 'a + ?Sized>(_, _);
Expand description

RMBA can store an &T, a &mut T, a Box or an Arc. It will panic if you try to store a struct that’s not 32 bit aligned.

Note: Drop flags were removed in 1.13-nightly. If you run an earlier version, size might be larger than a single pointer due to the drop flag.

Example

use reffers::RMBA;
use std::{iter, sync};

// Uses Box if only one clone is needed, otherwise uses Arc.
fn make_a_few<'a, T>(t: T, count: usize) -> Vec<RMBA<'a, T>> {
    match count {
        0 => vec![],
        1 => vec![RMBA::new_box(t)],
        _ => iter::repeat(sync::Arc::new(t))
            .take(count).map(|a| RMBA::from(a)).collect()
    }
}

Implementations

Will return a clone if it contains a Arc or &T, or None if it is a Box or &mut T

Will return a &mut to inner contents if it contains a &mut T, a Box or if the Arc is unique. Otherwise returns None.

Trait Implementations

Performs the conversion.

Immutably borrows from an owned value. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Executes the destructor for this type. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

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

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.

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.