[][src]Struct finarc::FinArc

pub struct FinArc<T, F> where
    T: ?Sized,
    F: FnOnce(&mut T), 
{ /* fields omitted */ }

Methods

impl<T, F> FinArc<T, F> where
    F: FnOnce(&mut T), 
[src]

pub fn new(data: T, finalizer: F) -> Self[src]

pub fn try_unwrap(this: Self) -> Result<T, Self>[src]

Returns the contained value, if this is the last instance of FinArc, without running finalizer

Otherwise, an Err is returned with the same FinArc that was passed in.

Examples

use finarc::FinArc;

let x = FinArc::new(3, |_|{});
assert_eq!(FinArc::try_unwrap(x), Ok(3));

let x = FinArc::new(4, |_|{});
let _y = FinArc::clone(&x);
assert_eq!(*FinArc::try_unwrap(x).unwrap_err(), 4);

Analogue of Arc::try_unwrap

Trait Implementations

impl<T, F> Clone for FinArc<T, F> where
    T: Clone,
    F: FnOnce(&mut T), 
[src]

impl<T: ?Sized + Debug, F: FnOnce(&mut T)> Debug for FinArc<T, F>[src]

impl<T, F> Deref for FinArc<T, F> where
    T: ?Sized,
    F: FnOnce(&mut T), 
[src]

type Target = T

The resulting type after dereferencing.

impl<T, F> DerefMut for FinArc<T, F> where
    T: ?Sized,
    F: FnOnce(&mut T), 
[src]

impl<T: ?Sized + Display, F: FnOnce(&mut T)> Display for FinArc<T, F>[src]

impl<T, F> Drop for FinArc<T, F> where
    T: ?Sized,
    F: FnOnce(&mut T), 
[src]

impl<T: ?Sized + Eq, F: FnOnce(&mut T)> Eq for FinArc<T, F>[src]

impl<T: ?Sized + Ord, F: FnOnce(&mut T)> Ord for FinArc<T, F>[src]

fn cmp(&self, other: &FinArc<T, F>) -> Ordering[src]

Comparison for two FinArcs.

The two are compared by calling cmp() on their inner values.

Examples

use finarc::FinArc;
use std::cmp::Ordering;

let five = FinArc::new(5, |_|{});
let mut six = FinArc::clone(&five);
*six = 6;

assert_eq!(Ordering::Less, five.cmp(&six));

impl<T: ?Sized, F, F1> PartialEq<FinArc<T, F1>> for FinArc<T, F> where
    T: PartialEq,
    F: FnOnce(&mut T),
    F1: FnOnce(&mut T), 
[src]

We ignore finalizers when comparing FinArc's, so they may be of different types

fn eq(&self, other: &FinArc<T, F1>) -> bool[src]

Equality for two FinArcs.

Two FinArcs are equal if their inner values are equal.

If T also implements Eq, two FinArcs that point to the same value are always equal.

Examples

use finarc::FinArc;

let five = FinArc::new(5, |_|{});

assert!(five == FinArc::new(5, |_|{}));

fn ne(&self, other: &FinArc<T, F1>) -> bool[src]

Inequality for two FinArcs.

Two FinArcs are unequal if their inner values are unequal.

If T also implements Eq, two FinArcs that point to the same value are never unequal.

Examples

use finarc::FinArc;

let five = FinArc::new(5, |_|{});

assert!(five != FinArc::new(6, |_|{}));

impl<T: ?Sized, F, F1> PartialOrd<FinArc<T, F1>> for FinArc<T, F> where
    T: PartialOrd,
    F: FnOnce(&mut T),
    F1: FnOnce(&mut T), 
[src]

We ignore finalizers when comparing FinArc's, so they may be of different types

fn partial_cmp(&self, other: &FinArc<T, F1>) -> Option<Ordering>[src]

Partial comparison for two FinArcs.

The two are compared by calling partial_cmp() on their inner values.

Examples

use finarc::FinArc;
use std::cmp::Ordering;

let five = FinArc::new(5, |_|{});

assert_eq!(Some(Ordering::Less), five.partial_cmp(&FinArc::new(6, |_|{})));

fn lt(&self, other: &FinArc<T, F1>) -> bool[src]

Less-than comparison for two FinArcs.

The two are compared by calling < on their inner values.

Examples

use finarc::FinArc;

let five = FinArc::new(5, |_|{});

assert!(five < FinArc::new(6, |_|{}));

fn le(&self, other: &FinArc<T, F1>) -> bool[src]

'Less than or equal to' comparison for two FinArcs.

The two are compared by calling <= on their inner values.

Examples

use finarc::FinArc;

let five = FinArc::new(5, |_|{});

assert!(five <= FinArc::new(5, |_|{}));

fn gt(&self, other: &FinArc<T, F1>) -> bool[src]

Greater-than comparison for two FinArcs.

The two are compared by calling > on their inner values.

Examples

use finarc::FinArc;

let five = FinArc::new(5, |_|{});

assert!(five > FinArc::new(4, |_|{}));

fn ge(&self, other: &FinArc<T, F1>) -> bool[src]

'Greater than or equal to' comparison for two FinArcs.

The two are compared by calling >= on their inner values.

Examples

use finarc::FinArc;

let five = FinArc::new(5, |_|{});

assert!(five >= FinArc::new(5, |_|{}));

Auto Trait Implementations

impl<T: ?Sized, F> RefUnwindSafe for FinArc<T, F> where
    F: RefUnwindSafe,
    T: RefUnwindSafe

impl<T: ?Sized, F> Send for FinArc<T, F> where
    F: Send + Sync,
    T: Send

impl<T: ?Sized, F> Sync for FinArc<T, F> where
    F: Send + Sync,
    T: Sync

impl<T: ?Sized, F> Unpin for FinArc<T, F> where
    T: Unpin

impl<T: ?Sized, F> UnwindSafe for FinArc<T, F> where
    F: RefUnwindSafe,
    T: UnwindSafe

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<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.