pub struct Cell<T>where
T: ?Sized,{ /* private fields */ }
Expand description
A mutable memory location.
Memory layout
Cell<T>
has the same memory layout and caveats as
UnsafeCell<T>
. In particular, this means that
Cell<T>
has the same in-memory representation as its inner type T
.
Examples
In this example, you can see that Cell<T>
enables mutation inside an
immutable struct. In other words, it enables “interior mutability”.
use std::cell::Cell;
struct SomeStruct {
regular_field: u8,
special_field: Cell<u8>,
}
let my_struct = SomeStruct {
regular_field: 0,
special_field: Cell::new(1),
};
let new_value = 100;
// ERROR: `my_struct` is immutable
// my_struct.regular_field = new_value;
// WORKS: although `my_struct` is immutable, `special_field` is a `Cell`,
// which can always be mutated
my_struct.special_field.set(new_value);
assert_eq!(my_struct.special_field.get(), new_value);
See the module-level documentation for more.
Implementations§
source§impl<T> Cell<T>
impl<T> Cell<T>
1.17.0 · sourcepub fn swap(&self, other: &Cell<T>)
pub fn swap(&self, other: &Cell<T>)
Swaps the values of two Cell
s.
Difference with std::mem::swap
is that this function doesn’t require &mut
reference.
Examples
use std::cell::Cell;
let c1 = Cell::new(5i32);
let c2 = Cell::new(10i32);
c1.swap(&c2);
assert_eq!(10, c1.get());
assert_eq!(5, c2.get());
1.17.0 · sourcepub fn replace(&self, val: T) -> T
pub fn replace(&self, val: T) -> T
Replaces the contained value with val
, and returns the old contained value.
Examples
use std::cell::Cell;
let cell = Cell::new(5);
assert_eq!(cell.get(), 5);
assert_eq!(cell.replace(10), 5);
assert_eq!(cell.get(), 10);
1.17.0 (const: unstable) · sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwraps the value, consuming the cell.
Examples
use std::cell::Cell;
let c = Cell::new(5);
let five = c.into_inner();
assert_eq!(five, 5);
source§impl<T> Cell<T>where
T: Copy,
impl<T> Cell<T>where T: Copy,
sourcepub fn get(&self) -> T
pub fn get(&self) -> T
Returns a copy of the contained value.
Examples
use std::cell::Cell;
let c = Cell::new(5);
let five = c.get();
sourcepub fn update<F>(&self, f: F) -> Twhere
F: FnOnce(T) -> T,
🔬This is a nightly-only experimental API. (cell_update
)
pub fn update<F>(&self, f: F) -> Twhere F: FnOnce(T) -> T,
cell_update
)Updates the contained value using a function and returns the new value.
Examples
#![feature(cell_update)]
use std::cell::Cell;
let c = Cell::new(5);
let new = c.update(|x| x + 1);
assert_eq!(new, 6);
assert_eq!(c.get(), 6);
source§impl<T> Cell<T>where
T: ?Sized,
impl<T> Cell<T>where T: ?Sized,
1.12.0 (const: 1.32.0) · sourcepub const fn as_ptr(&self) -> *mut T
pub const fn as_ptr(&self) -> *mut T
Returns a raw pointer to the underlying data in this cell.
Examples
use std::cell::Cell;
let c = Cell::new(5);
let ptr = c.as_ptr();
1.11.0 · sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Returns a mutable reference to the underlying data.
This call borrows Cell
mutably (at compile-time) which guarantees
that we possess the only reference.
However be cautious: this method expects self
to be mutable, which is
generally not the case when using a Cell
. If you require interior
mutability by reference, consider using RefCell
which provides
run-time checked mutable borrows through its borrow_mut
method.
Examples
use std::cell::Cell;
let mut c = Cell::new(5);
*c.get_mut() += 1;
assert_eq!(c.get(), 6);
1.37.0 · sourcepub fn from_mut(t: &mut T) -> &Cell<T>
pub fn from_mut(t: &mut T) -> &Cell<T>
Returns a &Cell<T>
from a &mut T
Examples
use std::cell::Cell;
let slice: &mut [i32] = &mut [1, 2, 3];
let cell_slice: &Cell<[i32]> = Cell::from_mut(slice);
let slice_cell: &[Cell<i32>] = cell_slice.as_slice_of_cells();
assert_eq!(slice_cell.len(), 3);
source§impl<T> Cell<[T]>
impl<T> Cell<[T]>
1.37.0 · sourcepub fn as_slice_of_cells(&self) -> &[Cell<T>]
pub fn as_slice_of_cells(&self) -> &[Cell<T>]
Returns a &[Cell<T>]
from a &Cell<[T]>
Examples
use std::cell::Cell;
let slice: &mut [i32] = &mut [1, 2, 3];
let cell_slice: &Cell<[i32]> = Cell::from_mut(slice);
let slice_cell: &[Cell<i32>] = cell_slice.as_slice_of_cells();
assert_eq!(slice_cell.len(), 3);
source§impl<T, const N: usize> Cell<[T; N]>
impl<T, const N: usize> Cell<[T; N]>
sourcepub fn as_array_of_cells(&self) -> &[Cell<T>; N]
🔬This is a nightly-only experimental API. (as_array_of_cells
)
pub fn as_array_of_cells(&self) -> &[Cell<T>; N]
as_array_of_cells
)Returns a &[Cell<T>; N]
from a &Cell<[T; N]>
Examples
#![feature(as_array_of_cells)]
use std::cell::Cell;
let mut array: [i32; 3] = [1, 2, 3];
let cell_array: &Cell<[i32; 3]> = Cell::from_mut(&mut array);
let array_cell: &[Cell<i32>; 3] = cell_array.as_array_of_cells();
Trait Implementations§
source§impl BitStore for Cell<u16>
impl BitStore for Cell<u16>
§type Mem = u16
type Mem = u16
BitSlice
. It
is always one of the unsigned integer fundamentals.§type Access = Cell<u16>
type Access = Cell<u16>
Self::Mem
value between the processor and the memory system. Read more§type Alias = Cell<u16>
type Alias = Cell<u16>
BitStore
implementor that is known to be alias-safe. It is
used when a BitSlice
introduces multiple handles that view the same
memory location, and at least one of them has write capabilities to it.
It must have the same underlying memory type, and can only change access
patterns or public-facing usage.§type Unalias = Cell<u16>
type Unalias = Cell<u16>
::Alias
. It is used when a BitSlice
removes the
conditions that required a T -> T::Alias
transition.source§fn new(value: <Cell<u16> as BitStore>::Mem) -> Cell<u16>
fn new(value: <Cell<u16> as BitStore>::Mem) -> Cell<u16>
BitStore
type.source§fn load_value(&self) -> <Cell<u16> as BitStore>::Mem
fn load_value(&self) -> <Cell<u16> as BitStore>::Mem
::Access
rules. This may be called when the value is aliased by a write-capable
reference.source§fn store_value(&mut self, value: <Cell<u16> as BitStore>::Mem)
fn store_value(&mut self, value: <Cell<u16> as BitStore>::Mem)
::Access
constraints.source§const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
source§impl BitStore for Cell<u32>
impl BitStore for Cell<u32>
§type Mem = u32
type Mem = u32
BitSlice
. It
is always one of the unsigned integer fundamentals.§type Access = Cell<u32>
type Access = Cell<u32>
Self::Mem
value between the processor and the memory system. Read more§type Alias = Cell<u32>
type Alias = Cell<u32>
BitStore
implementor that is known to be alias-safe. It is
used when a BitSlice
introduces multiple handles that view the same
memory location, and at least one of them has write capabilities to it.
It must have the same underlying memory type, and can only change access
patterns or public-facing usage.§type Unalias = Cell<u32>
type Unalias = Cell<u32>
::Alias
. It is used when a BitSlice
removes the
conditions that required a T -> T::Alias
transition.source§fn new(value: <Cell<u32> as BitStore>::Mem) -> Cell<u32>
fn new(value: <Cell<u32> as BitStore>::Mem) -> Cell<u32>
BitStore
type.source§fn load_value(&self) -> <Cell<u32> as BitStore>::Mem
fn load_value(&self) -> <Cell<u32> as BitStore>::Mem
::Access
rules. This may be called when the value is aliased by a write-capable
reference.source§fn store_value(&mut self, value: <Cell<u32> as BitStore>::Mem)
fn store_value(&mut self, value: <Cell<u32> as BitStore>::Mem)
::Access
constraints.source§const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
source§impl BitStore for Cell<u64>
impl BitStore for Cell<u64>
§type Mem = u64
type Mem = u64
BitSlice
. It
is always one of the unsigned integer fundamentals.§type Access = Cell<u64>
type Access = Cell<u64>
Self::Mem
value between the processor and the memory system. Read more§type Alias = Cell<u64>
type Alias = Cell<u64>
BitStore
implementor that is known to be alias-safe. It is
used when a BitSlice
introduces multiple handles that view the same
memory location, and at least one of them has write capabilities to it.
It must have the same underlying memory type, and can only change access
patterns or public-facing usage.§type Unalias = Cell<u64>
type Unalias = Cell<u64>
::Alias
. It is used when a BitSlice
removes the
conditions that required a T -> T::Alias
transition.source§fn new(value: <Cell<u64> as BitStore>::Mem) -> Cell<u64>
fn new(value: <Cell<u64> as BitStore>::Mem) -> Cell<u64>
BitStore
type.source§fn load_value(&self) -> <Cell<u64> as BitStore>::Mem
fn load_value(&self) -> <Cell<u64> as BitStore>::Mem
::Access
rules. This may be called when the value is aliased by a write-capable
reference.source§fn store_value(&mut self, value: <Cell<u64> as BitStore>::Mem)
fn store_value(&mut self, value: <Cell<u64> as BitStore>::Mem)
::Access
constraints.source§const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
source§impl BitStore for Cell<u8>
impl BitStore for Cell<u8>
§type Mem = u8
type Mem = u8
BitSlice
. It
is always one of the unsigned integer fundamentals.§type Access = Cell<u8>
type Access = Cell<u8>
Self::Mem
value between the processor and the memory system. Read more§type Alias = Cell<u8>
type Alias = Cell<u8>
BitStore
implementor that is known to be alias-safe. It is
used when a BitSlice
introduces multiple handles that view the same
memory location, and at least one of them has write capabilities to it.
It must have the same underlying memory type, and can only change access
patterns or public-facing usage.§type Unalias = Cell<u8>
type Unalias = Cell<u8>
::Alias
. It is used when a BitSlice
removes the
conditions that required a T -> T::Alias
transition.source§fn new(value: <Cell<u8> as BitStore>::Mem) -> Cell<u8>
fn new(value: <Cell<u8> as BitStore>::Mem) -> Cell<u8>
BitStore
type.source§fn load_value(&self) -> <Cell<u8> as BitStore>::Mem
fn load_value(&self) -> <Cell<u8> as BitStore>::Mem
::Access
rules. This may be called when the value is aliased by a write-capable
reference.source§fn store_value(&mut self, value: <Cell<u8> as BitStore>::Mem)
fn store_value(&mut self, value: <Cell<u8> as BitStore>::Mem)
::Access
constraints.source§const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
source§impl BitStore for Cell<usize>
impl BitStore for Cell<usize>
§type Mem = usize
type Mem = usize
BitSlice
. It
is always one of the unsigned integer fundamentals.§type Access = Cell<usize>
type Access = Cell<usize>
Self::Mem
value between the processor and the memory system. Read more§type Alias = Cell<usize>
type Alias = Cell<usize>
BitStore
implementor that is known to be alias-safe. It is
used when a BitSlice
introduces multiple handles that view the same
memory location, and at least one of them has write capabilities to it.
It must have the same underlying memory type, and can only change access
patterns or public-facing usage.§type Unalias = Cell<usize>
type Unalias = Cell<usize>
::Alias
. It is used when a BitSlice
removes the
conditions that required a T -> T::Alias
transition.source§fn new(value: <Cell<usize> as BitStore>::Mem) -> Cell<usize>
fn new(value: <Cell<usize> as BitStore>::Mem) -> Cell<usize>
BitStore
type.source§fn load_value(&self) -> <Cell<usize> as BitStore>::Mem
fn load_value(&self) -> <Cell<usize> as BitStore>::Mem
::Access
rules. This may be called when the value is aliased by a write-capable
reference.source§fn store_value(&mut self, value: <Cell<usize> as BitStore>::Mem)
fn store_value(&mut self, value: <Cell<usize> as BitStore>::Mem)
::Access
constraints.source§const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
const ALIGNED_TO_SIZE: [(); 1] = [(); mem::aligned_to_size::<Self>() as usize]
source§impl<'de, T> BorrowDecode<'de> for Cell<T>where
T: BorrowDecode<'de>,
impl<'de, T> BorrowDecode<'de> for Cell<T>where T: BorrowDecode<'de>,
source§fn borrow_decode<D>(decoder: &mut D) -> Result<Cell<T>, DecodeError>where
D: BorrowDecoder<'de>,
fn borrow_decode<D>(decoder: &mut D) -> Result<Cell<T>, DecodeError>where D: BorrowDecoder<'de>,
source§impl<'de, T> Deserialize<'de> for Cell<T>where
T: Deserialize<'de> + Copy,
impl<'de, T> Deserialize<'de> for Cell<T>where T: Deserialize<'de> + Copy,
source§fn deserialize<D>(
deserializer: D
) -> Result<Cell<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>( deserializer: D ) -> Result<Cell<T>, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,
1.10.0 · source§impl<T> Ord for Cell<T>where
T: Ord + Copy,
impl<T> Ord for Cell<T>where T: Ord + Copy,
1.10.0 · source§impl<T> PartialOrd<Cell<T>> for Cell<T>where
T: PartialOrd<T> + Copy,
impl<T> PartialOrd<Cell<T>> for Cell<T>where T: PartialOrd<T> + Copy,
§impl<T> Radium for Cell<*mut T>
impl<T> Radium for Cell<*mut T>
type Item = *mut T
§fn into_inner(self) -> *mut T
fn into_inner(self) -> *mut T
§fn swap(&self, value: *mut T, _: Ordering) -> *mut T
fn swap(&self, value: *mut T, _: Ordering) -> *mut T
§fn compare_and_swap(&self, current: *mut T, new: *mut T, _: Ordering) -> *mut T
fn compare_and_swap(&self, current: *mut T, new: *mut T, _: Ordering) -> *mut T
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: *mut T,
new: *mut T,
_: Ordering,
_: Ordering
) -> Result<*mut T, *mut T>
fn compare_exchange( &self, current: *mut T, new: *mut T, _: Ordering, _: Ordering ) -> Result<*mut T, *mut T>
current
value. Read more§impl Radium for Cell<bool>
impl Radium for Cell<bool>
type Item = bool
§fn into_inner(self) -> bool
fn into_inner(self) -> bool
§fn swap(&self, value: bool, _: Ordering) -> bool
fn swap(&self, value: bool, _: Ordering) -> bool
§fn compare_and_swap(&self, current: bool, new: bool, _: Ordering) -> bool
fn compare_and_swap(&self, current: bool, new: bool, _: Ordering) -> bool
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: bool,
new: bool,
_: Ordering,
_: Ordering
) -> Result<bool, bool>
fn compare_exchange( &self, current: bool, new: bool, _: Ordering, _: Ordering ) -> Result<bool, bool>
current
value. Read more§fn compare_exchange_weak(
&self,
current: bool,
new: bool,
success: Ordering,
failure: Ordering
) -> Result<bool, bool>
fn compare_exchange_weak( &self, current: bool, new: bool, success: Ordering, failure: Ordering ) -> Result<bool, bool>
current
value. Read more§fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<bool, bool>where
F: FnMut(bool) -> Option<bool>,
fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<bool, bool>where F: FnMut(bool) -> Option<bool>,
§fn fetch_and(&self, value: bool, _: Ordering) -> bool
fn fetch_and(&self, value: bool, _: Ordering) -> bool
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: bool, _: Ordering) -> bool
fn fetch_nand(&self, value: bool, _: Ordering) -> bool
value
, and stores the result in self
. Read more§impl Radium for Cell<i16>
impl Radium for Cell<i16>
type Item = i16
§fn into_inner(self) -> i16
fn into_inner(self) -> i16
§fn compare_and_swap(&self, current: i16, new: i16, _: Ordering) -> i16
fn compare_and_swap(&self, current: i16, new: i16, _: Ordering) -> i16
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: i16,
new: i16,
_: Ordering,
_: Ordering
) -> Result<i16, i16>
fn compare_exchange( &self, current: i16, new: i16, _: Ordering, _: Ordering ) -> Result<i16, i16>
current
value. Read more§fn compare_exchange_weak(
&self,
current: i16,
new: i16,
success: Ordering,
failure: Ordering
) -> Result<i16, i16>
fn compare_exchange_weak( &self, current: i16, new: i16, success: Ordering, failure: Ordering ) -> Result<i16, i16>
current
value. Read more§fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<i16, i16>where
F: FnMut(i16) -> Option<i16>,
fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<i16, i16>where F: FnMut(i16) -> Option<i16>,
§fn fetch_and(&self, value: i16, _: Ordering) -> i16
fn fetch_and(&self, value: i16, _: Ordering) -> i16
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: i16, _: Ordering) -> i16
fn fetch_nand(&self, value: i16, _: Ordering) -> i16
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: i16, _: Ordering) -> i16
fn fetch_or(&self, value: i16, _: Ordering) -> i16
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: i16, _: Ordering) -> i16
fn fetch_xor(&self, value: i16, _: Ordering) -> i16
value
, and stores the result in self
. Read more§impl Radium for Cell<i32>
impl Radium for Cell<i32>
type Item = i32
§fn into_inner(self) -> i32
fn into_inner(self) -> i32
§fn compare_and_swap(&self, current: i32, new: i32, _: Ordering) -> i32
fn compare_and_swap(&self, current: i32, new: i32, _: Ordering) -> i32
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: i32,
new: i32,
_: Ordering,
_: Ordering
) -> Result<i32, i32>
fn compare_exchange( &self, current: i32, new: i32, _: Ordering, _: Ordering ) -> Result<i32, i32>
current
value. Read more§fn compare_exchange_weak(
&self,
current: i32,
new: i32,
success: Ordering,
failure: Ordering
) -> Result<i32, i32>
fn compare_exchange_weak( &self, current: i32, new: i32, success: Ordering, failure: Ordering ) -> Result<i32, i32>
current
value. Read more§fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<i32, i32>where
F: FnMut(i32) -> Option<i32>,
fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<i32, i32>where F: FnMut(i32) -> Option<i32>,
§fn fetch_and(&self, value: i32, _: Ordering) -> i32
fn fetch_and(&self, value: i32, _: Ordering) -> i32
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: i32, _: Ordering) -> i32
fn fetch_nand(&self, value: i32, _: Ordering) -> i32
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: i32, _: Ordering) -> i32
fn fetch_or(&self, value: i32, _: Ordering) -> i32
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: i32, _: Ordering) -> i32
fn fetch_xor(&self, value: i32, _: Ordering) -> i32
value
, and stores the result in self
. Read more§impl Radium for Cell<i64>
impl Radium for Cell<i64>
type Item = i64
§fn into_inner(self) -> i64
fn into_inner(self) -> i64
§fn compare_and_swap(&self, current: i64, new: i64, _: Ordering) -> i64
fn compare_and_swap(&self, current: i64, new: i64, _: Ordering) -> i64
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: i64,
new: i64,
_: Ordering,
_: Ordering
) -> Result<i64, i64>
fn compare_exchange( &self, current: i64, new: i64, _: Ordering, _: Ordering ) -> Result<i64, i64>
current
value. Read more§fn compare_exchange_weak(
&self,
current: i64,
new: i64,
success: Ordering,
failure: Ordering
) -> Result<i64, i64>
fn compare_exchange_weak( &self, current: i64, new: i64, success: Ordering, failure: Ordering ) -> Result<i64, i64>
current
value. Read more§fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<i64, i64>where
F: FnMut(i64) -> Option<i64>,
fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<i64, i64>where F: FnMut(i64) -> Option<i64>,
§fn fetch_and(&self, value: i64, _: Ordering) -> i64
fn fetch_and(&self, value: i64, _: Ordering) -> i64
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: i64, _: Ordering) -> i64
fn fetch_nand(&self, value: i64, _: Ordering) -> i64
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: i64, _: Ordering) -> i64
fn fetch_or(&self, value: i64, _: Ordering) -> i64
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: i64, _: Ordering) -> i64
fn fetch_xor(&self, value: i64, _: Ordering) -> i64
value
, and stores the result in self
. Read more§impl Radium for Cell<i8>
impl Radium for Cell<i8>
type Item = i8
§fn into_inner(self) -> i8
fn into_inner(self) -> i8
§fn compare_and_swap(&self, current: i8, new: i8, _: Ordering) -> i8
fn compare_and_swap(&self, current: i8, new: i8, _: Ordering) -> i8
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: i8,
new: i8,
_: Ordering,
_: Ordering
) -> Result<i8, i8>
fn compare_exchange( &self, current: i8, new: i8, _: Ordering, _: Ordering ) -> Result<i8, i8>
current
value. Read more§fn compare_exchange_weak(
&self,
current: i8,
new: i8,
success: Ordering,
failure: Ordering
) -> Result<i8, i8>
fn compare_exchange_weak( &self, current: i8, new: i8, success: Ordering, failure: Ordering ) -> Result<i8, i8>
current
value. Read more§fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<i8, i8>where
F: FnMut(i8) -> Option<i8>,
fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<i8, i8>where F: FnMut(i8) -> Option<i8>,
§fn fetch_and(&self, value: i8, _: Ordering) -> i8
fn fetch_and(&self, value: i8, _: Ordering) -> i8
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: i8, _: Ordering) -> i8
fn fetch_nand(&self, value: i8, _: Ordering) -> i8
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: i8, _: Ordering) -> i8
fn fetch_or(&self, value: i8, _: Ordering) -> i8
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: i8, _: Ordering) -> i8
fn fetch_xor(&self, value: i8, _: Ordering) -> i8
value
, and stores the result in self
. Read more§impl Radium for Cell<isize>
impl Radium for Cell<isize>
type Item = isize
§fn into_inner(self) -> isize
fn into_inner(self) -> isize
§fn swap(&self, value: isize, _: Ordering) -> isize
fn swap(&self, value: isize, _: Ordering) -> isize
§fn compare_and_swap(&self, current: isize, new: isize, _: Ordering) -> isize
fn compare_and_swap(&self, current: isize, new: isize, _: Ordering) -> isize
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: isize,
new: isize,
_: Ordering,
_: Ordering
) -> Result<isize, isize>
fn compare_exchange( &self, current: isize, new: isize, _: Ordering, _: Ordering ) -> Result<isize, isize>
current
value. Read more§fn compare_exchange_weak(
&self,
current: isize,
new: isize,
success: Ordering,
failure: Ordering
) -> Result<isize, isize>
fn compare_exchange_weak( &self, current: isize, new: isize, success: Ordering, failure: Ordering ) -> Result<isize, isize>
current
value. Read more§fn fetch_update<F>(
&self,
_: Ordering,
_: Ordering,
f: F
) -> Result<isize, isize>where
F: FnMut(isize) -> Option<isize>,
fn fetch_update<F>( &self, _: Ordering, _: Ordering, f: F ) -> Result<isize, isize>where F: FnMut(isize) -> Option<isize>,
§fn fetch_and(&self, value: isize, _: Ordering) -> isize
fn fetch_and(&self, value: isize, _: Ordering) -> isize
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: isize, _: Ordering) -> isize
fn fetch_nand(&self, value: isize, _: Ordering) -> isize
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: isize, _: Ordering) -> isize
fn fetch_or(&self, value: isize, _: Ordering) -> isize
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: isize, _: Ordering) -> isize
fn fetch_xor(&self, value: isize, _: Ordering) -> isize
value
, and stores the result in self
. Read more§impl Radium for Cell<u16>
impl Radium for Cell<u16>
type Item = u16
§fn into_inner(self) -> u16
fn into_inner(self) -> u16
§fn compare_and_swap(&self, current: u16, new: u16, _: Ordering) -> u16
fn compare_and_swap(&self, current: u16, new: u16, _: Ordering) -> u16
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: u16,
new: u16,
_: Ordering,
_: Ordering
) -> Result<u16, u16>
fn compare_exchange( &self, current: u16, new: u16, _: Ordering, _: Ordering ) -> Result<u16, u16>
current
value. Read more§fn compare_exchange_weak(
&self,
current: u16,
new: u16,
success: Ordering,
failure: Ordering
) -> Result<u16, u16>
fn compare_exchange_weak( &self, current: u16, new: u16, success: Ordering, failure: Ordering ) -> Result<u16, u16>
current
value. Read more§fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<u16, u16>where
F: FnMut(u16) -> Option<u16>,
fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<u16, u16>where F: FnMut(u16) -> Option<u16>,
§fn fetch_and(&self, value: u16, _: Ordering) -> u16
fn fetch_and(&self, value: u16, _: Ordering) -> u16
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: u16, _: Ordering) -> u16
fn fetch_nand(&self, value: u16, _: Ordering) -> u16
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: u16, _: Ordering) -> u16
fn fetch_or(&self, value: u16, _: Ordering) -> u16
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: u16, _: Ordering) -> u16
fn fetch_xor(&self, value: u16, _: Ordering) -> u16
value
, and stores the result in self
. Read more§impl Radium for Cell<u32>
impl Radium for Cell<u32>
type Item = u32
§fn into_inner(self) -> u32
fn into_inner(self) -> u32
§fn compare_and_swap(&self, current: u32, new: u32, _: Ordering) -> u32
fn compare_and_swap(&self, current: u32, new: u32, _: Ordering) -> u32
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: u32,
new: u32,
_: Ordering,
_: Ordering
) -> Result<u32, u32>
fn compare_exchange( &self, current: u32, new: u32, _: Ordering, _: Ordering ) -> Result<u32, u32>
current
value. Read more§fn compare_exchange_weak(
&self,
current: u32,
new: u32,
success: Ordering,
failure: Ordering
) -> Result<u32, u32>
fn compare_exchange_weak( &self, current: u32, new: u32, success: Ordering, failure: Ordering ) -> Result<u32, u32>
current
value. Read more§fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<u32, u32>where
F: FnMut(u32) -> Option<u32>,
fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<u32, u32>where F: FnMut(u32) -> Option<u32>,
§fn fetch_and(&self, value: u32, _: Ordering) -> u32
fn fetch_and(&self, value: u32, _: Ordering) -> u32
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: u32, _: Ordering) -> u32
fn fetch_nand(&self, value: u32, _: Ordering) -> u32
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: u32, _: Ordering) -> u32
fn fetch_or(&self, value: u32, _: Ordering) -> u32
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: u32, _: Ordering) -> u32
fn fetch_xor(&self, value: u32, _: Ordering) -> u32
value
, and stores the result in self
. Read more§impl Radium for Cell<u64>
impl Radium for Cell<u64>
type Item = u64
§fn into_inner(self) -> u64
fn into_inner(self) -> u64
§fn compare_and_swap(&self, current: u64, new: u64, _: Ordering) -> u64
fn compare_and_swap(&self, current: u64, new: u64, _: Ordering) -> u64
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: u64,
new: u64,
_: Ordering,
_: Ordering
) -> Result<u64, u64>
fn compare_exchange( &self, current: u64, new: u64, _: Ordering, _: Ordering ) -> Result<u64, u64>
current
value. Read more§fn compare_exchange_weak(
&self,
current: u64,
new: u64,
success: Ordering,
failure: Ordering
) -> Result<u64, u64>
fn compare_exchange_weak( &self, current: u64, new: u64, success: Ordering, failure: Ordering ) -> Result<u64, u64>
current
value. Read more§fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<u64, u64>where
F: FnMut(u64) -> Option<u64>,
fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<u64, u64>where F: FnMut(u64) -> Option<u64>,
§fn fetch_and(&self, value: u64, _: Ordering) -> u64
fn fetch_and(&self, value: u64, _: Ordering) -> u64
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: u64, _: Ordering) -> u64
fn fetch_nand(&self, value: u64, _: Ordering) -> u64
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: u64, _: Ordering) -> u64
fn fetch_or(&self, value: u64, _: Ordering) -> u64
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: u64, _: Ordering) -> u64
fn fetch_xor(&self, value: u64, _: Ordering) -> u64
value
, and stores the result in self
. Read more§impl Radium for Cell<u8>
impl Radium for Cell<u8>
type Item = u8
§fn into_inner(self) -> u8
fn into_inner(self) -> u8
§fn compare_and_swap(&self, current: u8, new: u8, _: Ordering) -> u8
fn compare_and_swap(&self, current: u8, new: u8, _: Ordering) -> u8
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: u8,
new: u8,
_: Ordering,
_: Ordering
) -> Result<u8, u8>
fn compare_exchange( &self, current: u8, new: u8, _: Ordering, _: Ordering ) -> Result<u8, u8>
current
value. Read more§fn compare_exchange_weak(
&self,
current: u8,
new: u8,
success: Ordering,
failure: Ordering
) -> Result<u8, u8>
fn compare_exchange_weak( &self, current: u8, new: u8, success: Ordering, failure: Ordering ) -> Result<u8, u8>
current
value. Read more§fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<u8, u8>where
F: FnMut(u8) -> Option<u8>,
fn fetch_update<F>(&self, _: Ordering, _: Ordering, f: F) -> Result<u8, u8>where F: FnMut(u8) -> Option<u8>,
§fn fetch_and(&self, value: u8, _: Ordering) -> u8
fn fetch_and(&self, value: u8, _: Ordering) -> u8
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: u8, _: Ordering) -> u8
fn fetch_nand(&self, value: u8, _: Ordering) -> u8
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: u8, _: Ordering) -> u8
fn fetch_or(&self, value: u8, _: Ordering) -> u8
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: u8, _: Ordering) -> u8
fn fetch_xor(&self, value: u8, _: Ordering) -> u8
value
, and stores the result in self
. Read more§impl Radium for Cell<usize>
impl Radium for Cell<usize>
type Item = usize
§fn into_inner(self) -> usize
fn into_inner(self) -> usize
§fn swap(&self, value: usize, _: Ordering) -> usize
fn swap(&self, value: usize, _: Ordering) -> usize
§fn compare_and_swap(&self, current: usize, new: usize, _: Ordering) -> usize
fn compare_and_swap(&self, current: usize, new: usize, _: Ordering) -> usize
compare_exchange
or compare_exchange_weak
insteadcurrent
value. Read more§fn compare_exchange(
&self,
current: usize,
new: usize,
_: Ordering,
_: Ordering
) -> Result<usize, usize>
fn compare_exchange( &self, current: usize, new: usize, _: Ordering, _: Ordering ) -> Result<usize, usize>
current
value. Read more§fn compare_exchange_weak(
&self,
current: usize,
new: usize,
success: Ordering,
failure: Ordering
) -> Result<usize, usize>
fn compare_exchange_weak( &self, current: usize, new: usize, success: Ordering, failure: Ordering ) -> Result<usize, usize>
current
value. Read more§fn fetch_update<F>(
&self,
_: Ordering,
_: Ordering,
f: F
) -> Result<usize, usize>where
F: FnMut(usize) -> Option<usize>,
fn fetch_update<F>( &self, _: Ordering, _: Ordering, f: F ) -> Result<usize, usize>where F: FnMut(usize) -> Option<usize>,
§fn fetch_and(&self, value: usize, _: Ordering) -> usize
fn fetch_and(&self, value: usize, _: Ordering) -> usize
value
, and stores the result in self
. Read more§fn fetch_nand(&self, value: usize, _: Ordering) -> usize
fn fetch_nand(&self, value: usize, _: Ordering) -> usize
value
, and stores the result in self
. Read more§fn fetch_or(&self, value: usize, _: Ordering) -> usize
fn fetch_or(&self, value: usize, _: Ordering) -> usize
value
, and stores the result in self
. Read more§fn fetch_xor(&self, value: usize, _: Ordering) -> usize
fn fetch_xor(&self, value: usize, _: Ordering) -> usize
value
, and stores the result in self
. Read moresource§impl<T> Serialize for Cell<T>where
T: Serialize + Copy,
impl<T> Serialize for Cell<T>where T: Serialize + Copy,
source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,
impl<T, U> CoerceUnsized<Cell<U>> for Cell<T>where T: CoerceUnsized<U>,
impl<T, U> DispatchFromDyn<Cell<U>> for Cell<T>where T: DispatchFromDyn<U>,
impl<T> Eq for Cell<T>where T: Eq + Copy,
impl<T> Send for Cell<T>where T: Send + ?Sized,
impl<T> !Sync for Cell<T>where T: ?Sized,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Cell<T>
impl<T: ?Sized> Unpin for Cell<T>where T: Unpin,
impl<T: ?Sized> UnwindSafe for Cell<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BitView for Twhere
T: BitStore,
impl<T> BitView for Twhere T: BitStore,
source§fn view_bits<O>(&self) -> &BitSlice<T, O> ⓘwhere
O: BitOrder,
fn view_bits<O>(&self) -> &BitSlice<T, O> ⓘwhere O: BitOrder,
source§fn try_view_bits<O>(&self) -> Result<&BitSlice<T, O>, BitSpanError<T>>where
O: BitOrder,
fn try_view_bits<O>(&self) -> Result<&BitSlice<T, O>, BitSpanError<T>>where O: BitOrder,
source§fn view_bits_mut<O>(&mut self) -> &mut BitSlice<T, O> ⓘwhere
O: BitOrder,
fn view_bits_mut<O>(&mut self) -> &mut BitSlice<T, O> ⓘwhere O: BitOrder,
source§fn try_view_bits_mut<O>(
&mut self
) -> Result<&mut BitSlice<T, O>, BitSpanError<T>>where
O: BitOrder,
fn try_view_bits_mut<O>( &mut self ) -> Result<&mut BitSlice<T, O>, BitSpanError<T>>where O: BitOrder,
source§impl<T> BitViewSized for Twhere
T: BitStore,
impl<T> BitViewSized for Twhere T: BitStore,
source§fn as_raw_slice(&self) -> &[<T as BitView>::Store]
fn as_raw_slice(&self) -> &[<T as BitView>::Store]
source§fn as_raw_mut_slice(&mut self) -> &mut [<T as BitView>::Store]
fn as_raw_mut_slice(&mut self) -> &mut [<T as BitView>::Store]
source§fn into_bitarray<O>(self) -> BitArray<Self, O>where
O: BitOrder,
fn into_bitarray<O>(self) -> BitArray<Self, O>where O: BitOrder,
self
in a BitArray
.§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.