Struct FinArc

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

Implementations§

Source§

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

Source

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

Source

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

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§

Source§

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

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

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

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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

Source§

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

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));
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

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

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

Source§

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

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, |_|{}));
Source§

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

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, |_|{}));
Source§

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

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

Source§

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

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, |_|{})));
Source§

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

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, |_|{}));
Source§

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

‘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, |_|{}));
Source§

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

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, |_|{}));
Source§

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

‘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, |_|{}));
Source§

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

Auto Trait Implementations§

§

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

§

impl<T, F> RefUnwindSafe for FinArc<T, F>

§

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

§

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

§

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

§

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

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.