Struct yewtil::ptr::Irc [−][src]
pub struct Irc<T> { /* fields omitted */ }
Expand description
Immutable Reference Counted pointer.
The Irc
points to a value that cannot be mutated.
If a Mrc
and Irc
point to the same value, mutating the value via the Mrc
will
clone and allocate, then mutate the value, leaving the value pointed to by the Irc
alone.
Unless the Irc
is unwrapped, that value is mutated, and another Irc
is created using that value
the Irc
will guarantee that the value is not changed, and can be transparently passed to child components
with knowledge that its value matches that of an original Mrc
or Irc
that it was cloned from.
This makes Irc
s ideal for passing around immutable views to data through components in Yew, as
cloning the Irc
itself is cheap, and the Irc
guarantees that its data cannot be changed by
some intermediate component without obvious unwrap –> modify –> rewrap operations.
Implementations
impl<T> Irc<T>
[src]
impl<T> Irc<T>
[src]pub fn try_unwrap(self) -> Result<T, Self>
[src]
pub fn try_unwrap(self) -> Result<T, Self>
[src]Tries to extract the value from the Irc
, returning the Irc
if there is one or
more other smart pointers to the value.
Example
use yewtil::ptr::Irc; let irc = Irc::new(0); let clone = irc.clone(); let irc = irc.try_unwrap().expect_err("Should not be able to unwrap"); std::mem::drop(clone); let value = irc.try_unwrap().expect("Should get value");
pub fn get_count(&self) -> usize
[src]
pub fn get_count(&self) -> usize
[src]Gets the reference count of the Irc
.
An exclusive Irc
will have a count of 1
.
The count is incremented on any cloning action and is decremented when drop
is called.
Example
use yewtil::ptr::Irc; let irc = Irc::new(0); assert_eq!(irc.get_count(), 1); let _clone = irc.clone(); assert_eq!(irc.get_count(), 2); std::mem::drop(_clone); assert_eq!(irc.get_count(), 1);
pub fn is_exclusive(&self) -> bool
[src]
pub fn is_exclusive(&self) -> bool
[src]use yewtil::ptr::Irc; let irc = Irc::new(0); assert!(irc.is_exclusive()); let _clone = irc.clone(); assert!(!irc.is_exclusive()); std::mem::drop(_clone); assert!(irc.is_exclusive());
impl<T: Clone> Irc<T>
[src]
impl<T: Clone> Irc<T>
[src]pub fn unwrap_clone(self) -> T
[src]
pub fn unwrap_clone(self) -> T
[src]Unwraps the value from the Irc
, cloning the value instead if another Irc
or Mrc
points
to the same value.
pub fn clone_inner(&self) -> T
[src]
pub fn clone_inner(&self) -> T
[src]Clones the wrapped value of the Irc
.
Trait Implementations
impl<T: Ord> Ord for Irc<T>
[src]
impl<T: Ord> Ord for Irc<T>
[src]impl<T: PartialOrd> PartialOrd<Irc<T>> for Irc<T>
[src]
impl<T: PartialOrd> PartialOrd<Irc<T>> for Irc<T>
[src]fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: Eq> Eq for Irc<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for Irc<T>
impl<T> !Send for Irc<T>
impl<T> !Sync for Irc<T>
impl<T> Unpin for Irc<T>
impl<T> !UnwindSafe for Irc<T>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]pub fn equivalent(&self, key: &K) -> bool
[src]
pub fn equivalent(&self, key: &K) -> bool
[src]Compare self to key
and return true
if they are equal.
impl<T, V> IntoOptPropValue<V> for T where
T: IntoPropValue<Option<V>>,
[src]
impl<T, V> IntoOptPropValue<V> for T where
T: IntoPropValue<Option<V>>,
[src]pub fn into_opt_prop_value(self) -> Option<V>
[src]
pub fn into_opt_prop_value(self) -> Option<V>
[src]Convert self
to an optional value of a Properties
struct.
impl<T> IntoPropValue<Option<T>> for T
[src]
impl<T> IntoPropValue<Option<T>> for T
[src]pub fn into_prop_value(self) -> Option<T>
[src]
pub fn into_prop_value(self) -> Option<T>
[src]Convert self
to a value of a Properties
struct.
impl<T> IntoPropValue<T> for T
[src]
impl<T> IntoPropValue<T> for T
[src]pub fn into_prop_value(self) -> T
[src]
pub fn into_prop_value(self) -> T
[src]Convert self
to a value of a Properties
struct.
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> Any for T where
T: Any,
T: Any,
impl<T> CloneAny for T where
T: Any + Clone,
T: Any + Clone,