Struct static_rc::StaticRc[][src]

pub struct StaticRc<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<T, const N: usize> StaticRc<T, N, N>[src]

pub fn new(value: T) -> Self[src]

Constructs a new StaticRc<T, N, N>.

This uses Box under the hood.

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

Constructs a new Pin<StaticRc<T, N, N>>.

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

Returns the inner value.

impl<T: ?Sized, const N: usize> StaticRc<T, N, N>[src]

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

Returns a mutable reference into the given StaticRc.

pub fn into_box(this: Self) -> Box<T>[src]

Returns the inner value, boxed

impl<T: ?Sized, const NUM: usize, const DEN: usize> StaticRc<T, NUM, DEN>[src]

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

Consumes the StaticRc, returning the wrapped pointer.

To avoid a memory leak, the pointer must be converted back to Self using StaticRc::from_raw.

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

Provides a raw pointer to the data.

StaticRc is not consumed or affected in any way, the pointer is valid as long as there are shared owners of the value.

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 StaticRc<T, NUM, DEN> from a raw pointer.

The raw pointer must have been previously returned by a call to StaticRc<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: &StaticRc<T, N, D>
) -> bool
[src]

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

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

Notable traits for StaticRc<I, N, N>

impl<I: Iterator + ?Sized, const N: usize> Iterator for StaticRc<I, N, N> type Item = I::Item;impl<F: ?Sized + Future + Unpin, const N: usize> Future for StaticRc<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
) -> (StaticRc<T, A, DEN>, StaticRc<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
) -> [StaticRc<T, N, D>; DIM] where
    ((), ()): Sized,
    (): Sized
[src]

Splits the current instance into DIM instances with the specified Numerators and Denominators.

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: StaticRc<T, A, DEN>,
    right: StaticRc<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 StaticRc::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: StaticRc<T, A, DEN>,
    right: StaticRc<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.

impl<const NUM: usize, const DEN: usize> StaticRc<dyn Any, NUM, DEN>[src]

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

Attempts to downcast Self to a concrete type.

Trait Implementations

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

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

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

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

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

impl<T: Default, const N: usize> Default for StaticRc<T, N, N>[src]

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

type Target = T

The resulting type after dereferencing.

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

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

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

impl<T: ?Sized, const NUM: usize, const DEN: usize> Drop for StaticRc<T, NUM, DEN>[src]

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

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

impl<T: Copy, const N: usize> From<&'_ [T]> for StaticRc<[T], N, N>[src]

impl<const N: usize> From<&'_ str> for StaticRc<str, N, N>[src]

impl<T, const LEN: usize, const N: usize> From<[T; LEN]> for StaticRc<[T], N, N>[src]

impl<T: ?Sized, const N: usize> From<Box<T, Global>> for StaticRc<T, N, N>[src]

impl<T: Copy, const N: usize> From<Cow<'_, [T]>> for StaticRc<[T], N, N>[src]

impl<const N: usize> From<Cow<'_, str>> for StaticRc<str, N, N>[src]

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

impl<const N: usize> From<String> for StaticRc<str, N, N>[src]

impl<T, const N: usize> From<T> for StaticRc<T, N, N>[src]

impl<T, const N: usize> From<Vec<T, Global>> for StaticRc<[T], N, N>[src]

impl<T, const N: usize> FromIterator<T> for StaticRc<[T], N, N>[src]

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

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

type Output = F::Output

The type of value produced on completion.

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

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

type Item = I::Item

The type of the elements being iterated over.

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

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

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

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

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

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

impl<T: ?Sized, const NUM: usize, const DEN: usize> Unpin for StaticRc<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<!> for T[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.