Struct static_rc::StaticRcRef[][src]

pub struct StaticRcRef<'a, T: ?Sized, const NUM: usize, const DEN: usize> { /* fields omitted */ }

A compile-time reference-counted pointer.

The inherent methods of StaticRc are all associated functions to avoid conflicts with the the methods of the inner type T which are brought into scope by the Deref implementation.

The parameters NUM and DEN DENote the ratio (NUM / DEN) of ownership of the pointer:

  • The ratio is always in the (0, 1] interval, that is: NUM > 0 and NUM <= DEN.
  • When the ratio is equal to 1, that is when NUM == DEN, then the instance has full ownership of the pointee and extra capabilities are unlocked.

Implementations

impl<'a, T, const N: usize> StaticRcRef<'a, T, N, N>[src]

pub fn new(value: &'a mut T) -> Self[src]

Constructs a new StaticRcRef<'a, T, N, N>.

pub fn pin(value: &'a mut T) -> Pin<Self>[src]

Constructs a new Pin<StaticRcRef<'a, T, N, N>>.

pub fn into_inner(this: Self) -> &'a mut T[src]

Returns the inner value.

impl<'a, T: ?Sized, const N: usize> StaticRcRef<'a, T, N, N>[src]

pub fn get_mut(this: &mut Self) -> &mut T[src]

Returns a mutable reference into the given StaticRcRef.

impl<'a, T: ?Sized, const NUM: usize, const DEN: usize> StaticRcRef<'a, T, NUM, DEN>[src]

pub fn into_raw(this: Self) -> NonNull<T>[src]

Consumes the StaticRcRef, returning the wrapped pointer.

pub fn as_ptr(this: &Self) -> NonNull<T>[src]

Provides a raw pointer to the data.

StaticRcRef is not consumed or affected in any way, the pointer is valid as long as the original value is.

pub fn get_ref(this: &Self) -> &T[src]

Provides a reference to the data.

pub unsafe fn from_raw(pointer: NonNull<T>) -> Self[src]

Constructs a StaticRcRef<'a, T, NUM, DEN> from a raw pointer.

The raw pointer must have been previously returned by a call to StaticRcRef<'a, U, N, D>::into_raw:

  • If U is different from T, then specific restrictions on size and alignment apply. See mem::transmute for the restrictions applying to transmuting references.
  • If N / D is different from NUM / DEN, then specific restrictions apply. The user is responsible for ensuring proper management of the ratio of shares, and ultimately that the value is not dropped twice.

pub fn ptr_eq<const N: usize, const D: usize>(
    this: &Self,
    other: &StaticRcRef<'a, T, N, D>
) -> bool
[src]

Returns true if the two StaticRcRef point to the same allocation.

pub fn adjust<const N: usize, const D: usize>(
    this: Self
) -> StaticRcRef<'a, T, N, D>

Notable traits for StaticRcRef<'a, I, N, N>

impl<'a, I: Iterator + ?Sized, const N: usize> Iterator for StaticRcRef<'a, I, N, N> type Item = I::Item;impl<'a, F: ?Sized + Future + Unpin, const N: usize> Future for StaticRcRef<'a, F, N, N> type Output = F::Output;
where
    ((), ()): Sized
[src]

Adjusts the NUMerator and DENumerator of the ratio of the instance, preserving the ratio.

Panics

If the compile-time-ratio feature is not used, and the ratio is not preserved; that is N / D <> NUM / DEN.

pub fn split<const A: usize, const B: usize>(
    this: Self
) -> (StaticRcRef<'a, T, A, DEN>, StaticRcRef<'a, T, B, DEN>) where
    ((), ()): Sized
[src]

Splits the current instance into two instances with the specified NUMerators.

Panics

If the compile-time-ratio feature is not used, and the ratio is not preserved; that is A + B <> NUM.

pub fn split_array<const N: usize, const D: usize, const DIM: usize>(
    this: Self
) -> [StaticRcRef<'a, T, N, D>; DIM] where
    T: 'a,
    ((), ()): Sized,
    (): Sized
[src]

Splits the current instance into two instances with the specified NUMerators.

Panics

If the compile-time-ratio feature is not used, and the ratio is not preserved; that is N * DIM / D <> NUM / DEN.

pub fn join<const A: usize, const B: usize>(
    left: StaticRcRef<'a, T, A, DEN>,
    right: StaticRcRef<'a, T, B, DEN>
) -> Self where
    ((), ()): Sized
[src]

Joins two instances into a single instance.

Panics

If the two instances do no point to the same allocation, as determined by StaticRcRef::ptr_eq.

If the compile-time-ratio feature is not used and the ratio is not preserved; that is A + B <> NUM.

pub unsafe fn join_unchecked<const A: usize, const B: usize>(
    left: StaticRcRef<'a, T, A, DEN>,
    _right: StaticRcRef<'a, T, B, DEN>
) -> Self where
    ((), ()): Sized
[src]

Joins two instances into a single instance without checking whether they point to the same allocation.

Unless compile-time-ratio is activated, the ratios are checked nevertheless.

Safety

The caller must guarantee that those instances point to the same allocation.

Panics

If the compile-time-ratio feature is not used and the ratio is not preserved; that is A + B <> NUM.

pub fn lift<'b, F>(this: Self, fun: F) -> Option<Self> where
    'a: 'b,
    T: 'b,
    F: FnOnce(&'b Self) -> &'b mut Option<Self>, 
[src]

Lifts this into the slot provided by fun; returns the previous value of the slot, if any.

This function is useful, for example, to “tie the knot” when appending 2 linked-lists: it is easy to splice the the head of the back linked-list at the back of the front linked-list, but then one has lost the head pointer and can no longer splice the tail of the front linked-list to it.

impl<'a, const NUM: usize, const DEN: usize> StaticRcRef<'a, dyn Any, NUM, DEN>[src]

pub fn downcast<T: Any>(self) -> Result<StaticRcRef<'a, T, NUM, DEN>, Self>[src]

Attempts to downcast Self to a concrete type.

Trait Implementations

impl<'a, T: ?Sized, const N: usize> AsMut<T> for StaticRcRef<'a, T, N, N>[src]

impl<'a, T: ?Sized, const NUM: usize, const DEN: usize> AsRef<T> for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, T: ?Sized, const NUM: usize, const DEN: usize> Borrow<T> for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, T: ?Sized, const N: usize> BorrowMut<T> for StaticRcRef<'a, T, N, N>[src]

impl<'a, T: ?Sized + Debug, const NUM: usize, const DEN: usize> Debug for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, T: ?Sized, const NUM: usize, const DEN: usize> Deref for StaticRcRef<'a, T, NUM, DEN>[src]

type Target = T

The resulting type after dereferencing.

impl<'a, T: ?Sized, const N: usize> DerefMut for StaticRcRef<'a, T, N, N>[src]

impl<'a, T: ?Sized + Display, const NUM: usize, const DEN: usize> Display for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, I: DoubleEndedIterator + ?Sized, const N: usize> DoubleEndedIterator for StaticRcRef<'a, I, N, N>[src]

impl<'a, T: ?Sized + Eq, const NUM: usize, const DEN: usize> Eq for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, I: ExactSizeIterator + ?Sized, const N: usize> ExactSizeIterator for StaticRcRef<'a, I, N, N>[src]

impl<'a, const NUM: usize, const DEN: usize> From<StaticRcRef<'a, str, NUM, DEN>> for StaticRcRef<'a, [u8], NUM, DEN>[src]

impl<'a, I: FusedIterator + ?Sized, const N: usize> FusedIterator for StaticRcRef<'a, I, N, N>[src]

impl<'a, F: ?Sized + Future + Unpin, const N: usize> Future for StaticRcRef<'a, F, N, N>[src]

type Output = F::Output

The type of value produced on completion.

impl<'a, T: ?Sized + Hash, const NUM: usize, const DEN: usize> Hash for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, I: Iterator + ?Sized, const N: usize> Iterator for StaticRcRef<'a, I, N, N>[src]

type Item = I::Item

The type of the elements being iterated over.

impl<'a, T: ?Sized + Ord, const NUM: usize, const DEN: usize> Ord for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, T: ?Sized, const NUM: usize, const DEN: usize, const N: usize, const D: usize> PartialEq<StaticRcRef<'a, T, N, D>> for StaticRcRef<'a, T, NUM, DEN> where
    T: PartialEq<T>, 
[src]

impl<'a, T: ?Sized, const NUM: usize, const DEN: usize, const N: usize, const D: usize> PartialOrd<StaticRcRef<'a, T, N, D>> for StaticRcRef<'a, T, NUM, DEN> where
    T: PartialOrd<T>, 
[src]

impl<'a, T: ?Sized, const NUM: usize, const DEN: usize> Pointer for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, T: ?Sized + Send, const NUM: usize, const DEN: usize> Send for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, T: ?Sized + Sync, const NUM: usize, const DEN: usize> Sync for StaticRcRef<'a, T, NUM, DEN>[src]

impl<'a, T: ?Sized, const NUM: usize, const DEN: usize> Unpin for StaticRcRef<'a, T, NUM, DEN>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<F> IntoFuture for F where
    F: Future
[src]

type Output = <F as Future>::Output

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

The output that the future will produce on completion.

type Future = F

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

Which kind of future are we turning this into?

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.