Struct rant::RantListHandle
source · [−]pub struct RantListHandle(_);
Expand description
Reference handle for a Rant list
Implementations
sourceimpl RantListHandle
impl RantListHandle
Methods from Deref<Target = RefCell<RantList>>
1.24.0 · sourcepub fn replace(&self, t: T) -> T
pub fn replace(&self, t: T) -> T
Replaces the wrapped value with a new one, returning the old value, without deinitializing either one.
This function corresponds to std::mem::replace
.
Panics
Panics if the value is currently borrowed.
Examples
use std::cell::RefCell;
let cell = RefCell::new(5);
let old_value = cell.replace(6);
assert_eq!(old_value, 5);
assert_eq!(cell, RefCell::new(6));
1.35.0 · sourcepub fn replace_with<F>(&self, f: F) -> T where
F: FnOnce(&mut T) -> T,
pub fn replace_with<F>(&self, f: F) -> T where
F: FnOnce(&mut T) -> T,
Replaces the wrapped value with a new one computed from f
, returning
the old value, without deinitializing either one.
Panics
Panics if the value is currently borrowed.
Examples
use std::cell::RefCell;
let cell = RefCell::new(5);
let old_value = cell.replace_with(|&mut old| old + 1);
assert_eq!(old_value, 5);
assert_eq!(cell, RefCell::new(6));
1.24.0 · sourcepub fn swap(&self, other: &RefCell<T>)
pub fn swap(&self, other: &RefCell<T>)
Swaps the wrapped value of self
with the wrapped value of other
,
without deinitializing either one.
This function corresponds to std::mem::swap
.
Panics
Panics if the value in either RefCell
is currently borrowed.
Examples
use std::cell::RefCell;
let c = RefCell::new(5);
let d = RefCell::new(6);
c.swap(&d);
assert_eq!(c, RefCell::new(6));
assert_eq!(d, RefCell::new(5));
1.0.0 · sourcepub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Immutably borrows the wrapped value.
The borrow lasts until the returned Ref
exits scope. Multiple
immutable borrows can be taken out at the same time.
Panics
Panics if the value is currently mutably borrowed. For a non-panicking variant, use
try_borrow
.
Examples
use std::cell::RefCell;
let c = RefCell::new(5);
let borrowed_five = c.borrow();
let borrowed_five2 = c.borrow();
An example of panic:
use std::cell::RefCell;
let c = RefCell::new(5);
let m = c.borrow_mut();
let b = c.borrow(); // this causes a panic
1.13.0 · sourcepub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
pub fn try_borrow(&self) -> Result<Ref<'_, T>, BorrowError>
Immutably borrows the wrapped value, returning an error if the value is currently mutably borrowed.
The borrow lasts until the returned Ref
exits scope. Multiple immutable borrows can be
taken out at the same time.
This is the non-panicking variant of borrow
.
Examples
use std::cell::RefCell;
let c = RefCell::new(5);
{
let m = c.borrow_mut();
assert!(c.try_borrow().is_err());
}
{
let m = c.borrow();
assert!(c.try_borrow().is_ok());
}
1.0.0 · sourcepub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
Mutably borrows the wrapped value.
The borrow lasts until the returned RefMut
or all RefMut
s derived
from it exit scope. The value cannot be borrowed while this borrow is
active.
Panics
Panics if the value is currently borrowed. For a non-panicking variant, use
try_borrow_mut
.
Examples
use std::cell::RefCell;
let c = RefCell::new("hello".to_owned());
*c.borrow_mut() = "bonjour".to_owned();
assert_eq!(&*c.borrow(), "bonjour");
An example of panic:
use std::cell::RefCell;
let c = RefCell::new(5);
let m = c.borrow();
let b = c.borrow_mut(); // this causes a panic
1.13.0 · sourcepub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
pub fn try_borrow_mut(&self) -> Result<RefMut<'_, T>, BorrowMutError>
Mutably borrows the wrapped value, returning an error if the value is currently borrowed.
The borrow lasts until the returned RefMut
or all RefMut
s derived
from it exit scope. The value cannot be borrowed while this borrow is
active.
This is the non-panicking variant of borrow_mut
.
Examples
use std::cell::RefCell;
let c = RefCell::new(5);
{
let m = c.borrow();
assert!(c.try_borrow_mut().is_err());
}
assert!(c.try_borrow_mut().is_ok());
1.12.0 · sourcepub fn as_ptr(&self) -> *mut T
pub fn as_ptr(&self) -> *mut T
Returns a raw pointer to the underlying data in this cell.
Examples
use std::cell::RefCell;
let c = RefCell::new(5);
let ptr = c.as_ptr();
1.37.0 · sourcepub unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError>
pub unsafe fn try_borrow_unguarded(&self) -> Result<&T, BorrowError>
Immutably borrows the wrapped value, returning an error if the value is currently mutably borrowed.
Safety
Unlike RefCell::borrow
, this method is unsafe because it does not
return a Ref
, thus leaving the borrow flag untouched. Mutably
borrowing the RefCell
while the reference returned by this method
is alive is undefined behaviour.
Examples
use std::cell::RefCell;
let c = RefCell::new(5);
{
let m = c.borrow_mut();
assert!(unsafe { c.try_borrow_unguarded() }.is_err());
}
{
let m = c.borrow();
assert!(unsafe { c.try_borrow_unguarded() }.is_ok());
}
Trait Implementations
sourceimpl Add<RantListHandle> for RantListHandle
impl Add<RantListHandle> for RantListHandle
sourceimpl Add<RantListHandle> for RantTupleHandle
impl Add<RantListHandle> for RantTupleHandle
type Output = RantListHandle
type Output = RantListHandle
The resulting type after applying the +
operator.
sourcefn add(self, rhs: RantListHandle) -> Self::Output
fn add(self, rhs: RantListHandle) -> Self::Output
Performs the +
operation. Read more
sourceimpl Add<RantTupleHandle> for RantListHandle
impl Add<RantTupleHandle> for RantListHandle
type Output = RantListHandle
type Output = RantListHandle
The resulting type after applying the +
operator.
sourcefn add(self, rhs: RantTupleHandle) -> Self::Output
fn add(self, rhs: RantTupleHandle) -> Self::Output
Performs the +
operation. Read more
sourceimpl Clone for RantListHandle
impl Clone for RantListHandle
sourcefn clone(&self) -> RantListHandle
fn clone(&self) -> RantListHandle
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for RantListHandle
impl Debug for RantListHandle
sourceimpl Deref for RantListHandle
impl Deref for RantListHandle
sourceimpl From<RantList> for RantListHandle
impl From<RantList> for RantListHandle
sourceimpl PartialEq<RantListHandle> for RantListHandle
impl PartialEq<RantListHandle> for RantListHandle
sourcefn eq(&self, other: &RantListHandle) -> bool
fn eq(&self, other: &RantListHandle) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &RantListHandle) -> bool
fn ne(&self, other: &RantListHandle) -> bool
This method tests for !=
.
sourceimpl TryFromRant for RantListHandle
impl TryFromRant for RantListHandle
sourcefn try_from_rant(val: RantValue) -> ValueResult<Self>
fn try_from_rant(val: RantValue) -> ValueResult<Self>
Convert from a RantValue
.
sourcefn is_optional_param_type() -> bool
fn is_optional_param_type() -> bool
Returns true
if the type can be used to represent an optional Rant parameter in native functions; otherwise, false
.
sourceimpl TryIntoRant for RantListHandle
impl TryIntoRant for RantListHandle
sourcefn try_into_rant(self) -> Result<RantValue, ValueError>
fn try_into_rant(self) -> Result<RantValue, ValueError>
Attempts to convert to a RantValue
.
impl StructuralPartialEq for RantListHandle
Auto Trait Implementations
impl !RefUnwindSafe for RantListHandle
impl !Send for RantListHandle
impl !Sync for RantListHandle
impl Unpin for RantListHandle
impl !UnwindSafe for RantListHandle
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more