proptest/arbitrary/_core/
cell.rs1use core::cell::{BorrowError, BorrowMutError, Cell, RefCell, UnsafeCell};
13
14wrap_from!([Copy] Cell);
15wrap_from!(RefCell);
16wrap_from!(UnsafeCell);
17
18lazy_just!(BorrowError, || {
19 #[cfg_attr(clippy, allow(let_and_return))]
21 {
22 let _rc = RefCell::new(());
23 let _bm = _rc.borrow_mut();
24 let _tb = _rc.try_borrow();
25 let ret = _rc.try_borrow().expect_err("reborrowed RefCell");
26 ret
27 }
28});
29lazy_just!(BorrowMutError, || {
30 #[cfg_attr(clippy, allow(let_and_return))]
32 {
33 let _rc = RefCell::new(());
34 let _bm = _rc.borrow_mut();
35 let _tb = _rc.try_borrow();
36 let ret = _rc.try_borrow_mut().expect_err("reborrowed RefCell");
37 ret
38 }
39});
40
41#[cfg(test)]
42mod test {
43 no_panic_test!(
44 cell => Cell<u8>,
45 ref_cell => RefCell<u8>,
46 unsafe_cell => UnsafeCell<u8>
47 );
48}