Lines Matching refs:cell

52 use std::cell::UnsafeCell;
72 /// Put a value into this cell.
74 /// This function will return `Err(value)` is the cell is already full.
85 /// Put a value into this cell.
89 /// cell can exist so we can always fill in the value. This may not always
99 /// Test whether this cell has been previously filled.
104 /// Borrows the contents of this lazy cell for the duration of the cell
107 /// This function will return `Some` if the cell has been previously
113 /// Borrows the contents of this lazy cell mutably for the duration of the cell
116 /// This function will return `Some` if the cell has been previously
122 /// Borrows the contents of this lazy cell for the duration of the cell
125 /// If the cell has not yet been filled, the cell is first filled using the
130 /// Panics if the cell becomes filled as a side effect of `f`.
137 panic!("borrow_with: cell was filled by closure")
143 /// cell itself.
145 /// If the cell has not yet been filled, the cell is first filled using the
150 /// Panics if the cell becomes filled as a side effect of `f`.
155 panic!("borrow_mut_with: cell was filled by closure")
166 /// Panics if the cell becomes filled as a side effect of `f`.
175 panic!("try_borrow_with: cell was filled by closure")
184 /// Panics if the cell becomes filled as a side effect of `f`.
193 panic!("try_borrow_mut_with: cell was filled by closure")
209 /// Returns a copy of the contents of the lazy cell.
211 /// This function will return `Some` if the cell has been previously initialized,
253 /// Put a value into this cell.
255 /// This function will return `Err(value)` is the cell is already full.
270 /// Put a value into this cell.
274 /// cell can exist so we can always fill in the value. This may not always
283 _ => panic!("cell in inconsistent state"),
288 /// Test whether this cell has been previously filled.
293 /// Borrows the contents of this lazy cell for the duration of the cell
296 /// This function will return `Some` if the cell has been previously
316 /// Returns a copy of the contents of the lazy cell.
318 /// This function will return `Some` if the cell has been previously initialized,
390 // official way to reset the cell
593 let mut cell = LazyCell::new();
594 assert_eq!(cell.fill(1), Ok(()));
595 assert_eq!(cell.replace(2), Some(1));
596 assert_eq!(cell.replace(3), Some(2));
597 assert_eq!(cell.borrow(), Some(&3));
599 let mut cell = LazyCell::new();
600 assert_eq!(cell.replace(2), None);
605 let mut cell = AtomicLazyCell::new();
606 assert_eq!(cell.fill(1), Ok(()));
607 assert_eq!(cell.replace(2), Some(1));
608 assert_eq!(cell.replace(3), Some(2));
609 assert_eq!(cell.borrow(), Some(&3));
614 let mut cell = LazyCell::new();
615 let clone1 = cell.clone();
617 assert_eq!(cell.fill(1), Ok(()));
618 let mut clone2 = cell.clone();
621 assert_eq!(cell.replace(2), Some(1));
628 assert_eq!(cell.borrow(), Some(&2));
633 let mut cell = AtomicLazyCell::new();
634 let clone1 = cell.clone();
636 assert_eq!(cell.fill(1), Ok(()));
637 let mut clone2 = cell.clone();
640 assert_eq!(cell.replace(2), Some(1));
647 assert_eq!(cell.borrow(), Some(&2));