pub struct FinArc<T, F>{ /* private fields */ }
Implementations§
Source§impl<T, F> FinArc<T, F>
impl<T, F> FinArc<T, F>
pub fn new(data: T, finalizer: F) -> Self
Sourcepub fn try_unwrap(this: Self) -> Result<T, Self>
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: ?Sized + Ord, F: FnOnce(&mut T)> Ord for FinArc<T, F>
impl<T: ?Sized + Ord, F: FnOnce(&mut T)> Ord for FinArc<T, F>
Source§fn cmp(&self, other: &FinArc<T, F>) -> Ordering
fn cmp(&self, other: &FinArc<T, F>) -> Ordering
Comparison for two FinArc
s.
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) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T, F, F1> PartialEq<FinArc<T, F1>> for FinArc<T, F>
We ignore finalizers when comparing FinArc’s, so they may be of different types
impl<T, F, F1> PartialEq<FinArc<T, F1>> for FinArc<T, F>
We ignore finalizers when comparing FinArc’s, so they may be of different types
Source§fn eq(&self, other: &FinArc<T, F1>) -> bool
fn eq(&self, other: &FinArc<T, F1>) -> bool
Equality for two FinArc
s.
Two FinArc
s are equal if their inner values are equal.
If T
also implements Eq
, two FinArc
s 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
fn ne(&self, other: &FinArc<T, F1>) -> bool
Inequality for two FinArc
s.
Two FinArc
s are unequal if their inner values are unequal.
If T
also implements Eq
, two FinArc
s 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>
We ignore finalizers when comparing FinArc’s, so they may be of different types
impl<T, F, F1> PartialOrd<FinArc<T, F1>> for FinArc<T, F>
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>
fn partial_cmp(&self, other: &FinArc<T, F1>) -> Option<Ordering>
Partial comparison for two FinArc
s.
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
fn lt(&self, other: &FinArc<T, F1>) -> bool
Less-than comparison for two FinArc
s.
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
fn le(&self, other: &FinArc<T, F1>) -> bool
‘Less than or equal to’ comparison for two FinArc
s.
The two are compared by calling <=
on their inner values.
§Examples
use finarc::FinArc;
let five = FinArc::new(5, |_|{});
assert!(five <= FinArc::new(5, |_|{}));