Lines Matching refs:lazycell
374 let lazycell: LazyCell<usize> = LazyCell::new(); in test_borrow_from_empty() localVariable
376 let value = lazycell.borrow(); in test_borrow_from_empty()
379 let value = lazycell.get(); in test_borrow_from_empty()
385 let lazycell = LazyCell::new(); in test_fill_and_borrow() localVariable
387 assert!(!lazycell.filled()); in test_fill_and_borrow()
388 lazycell.fill(1).unwrap(); in test_fill_and_borrow()
389 assert!(lazycell.filled()); in test_fill_and_borrow()
391 let value = lazycell.borrow(); in test_fill_and_borrow()
394 let value = lazycell.get(); in test_fill_and_borrow()
400 let mut lazycell = LazyCell::new(); in test_borrow_mut() localVariable
401 assert!(lazycell.borrow_mut().is_none()); in test_borrow_mut()
403 lazycell.fill(1).unwrap(); in test_borrow_mut()
404 assert_eq!(lazycell.borrow_mut(), Some(&mut 1)); in test_borrow_mut()
406 *lazycell.borrow_mut().unwrap() = 2; in test_borrow_mut()
407 assert_eq!(lazycell.borrow_mut(), Some(&mut 2)); in test_borrow_mut()
410 lazycell = LazyCell::new(); in test_borrow_mut()
411 assert!(lazycell.borrow_mut().is_none()); in test_borrow_mut()
416 let lazycell = LazyCell::new(); in test_already_filled_error() localVariable
418 lazycell.fill(1).unwrap(); in test_already_filled_error()
419 assert_eq!(lazycell.fill(1), Err(1)); in test_already_filled_error()
424 let lazycell = LazyCell::new(); in test_borrow_with() localVariable
426 let value = lazycell.borrow_with(|| 1); in test_borrow_with()
432 let lazycell = LazyCell::new(); in test_borrow_with_already_filled() localVariable
433 lazycell.fill(1).unwrap(); in test_borrow_with_already_filled()
435 let value = lazycell.borrow_with(|| 1); in test_borrow_with_already_filled()
441 let lazycell = LazyCell::new(); in test_borrow_with_not_called_when_filled() localVariable
443 lazycell.fill(1).unwrap(); in test_borrow_with_not_called_when_filled()
445 let value = lazycell.borrow_with(|| 2); in test_borrow_with_not_called_when_filled()
454 let lazycell: LazyCell<Box<i32>> = LazyCell::new(); in test_borrow_with_sound_with_reentrancy() localVariable
458 lazycell.borrow_with(|| { in test_borrow_with_sound_with_reentrancy()
459 let _ = lazycell.fill(Box::new(1)); in test_borrow_with_sound_with_reentrancy()
460 reference = lazycell.borrow().map(|r| &**r); in test_borrow_with_sound_with_reentrancy()
467 let mut lazycell = LazyCell::new(); in test_borrow_mut_with() localVariable
470 let value = lazycell.borrow_mut_with(|| 1); in test_borrow_mut_with()
474 assert_eq!(&2, lazycell.borrow().unwrap()); in test_borrow_mut_with()
479 let mut lazycell = LazyCell::new(); in test_borrow_mut_with_already_filled() localVariable
480 lazycell.fill(1).unwrap(); in test_borrow_mut_with_already_filled()
482 let value = lazycell.borrow_mut_with(|| 1); in test_borrow_mut_with_already_filled()
488 let mut lazycell = LazyCell::new(); in test_borrow_mut_with_not_called_when_filled() localVariable
490 lazycell.fill(1).unwrap(); in test_borrow_mut_with_not_called_when_filled()
492 let value = lazycell.borrow_mut_with(|| 2); in test_borrow_mut_with_not_called_when_filled()
498 let lazycell = LazyCell::new(); in test_try_borrow_with_ok() localVariable
499 let result = lazycell.try_borrow_with::<(), _>(|| Ok(1)); in test_try_borrow_with_ok()
505 let lazycell = LazyCell::<()>::new(); in test_try_borrow_with_err() localVariable
506 let result = lazycell.try_borrow_with(|| Err(1)); in test_try_borrow_with_err()
512 let lazycell = LazyCell::new(); in test_try_borrow_with_already_filled() localVariable
513 lazycell.fill(1).unwrap(); in test_try_borrow_with_already_filled()
514 let result = lazycell.try_borrow_with::<(), _>(|| unreachable!()); in test_try_borrow_with_already_filled()
521 let lazycell: LazyCell<Box<i32>> = LazyCell::new(); in test_try_borrow_with_sound_with_reentrancy() localVariable
525 let _ = lazycell.try_borrow_with::<(), _>(|| { in test_try_borrow_with_sound_with_reentrancy()
526 let _ = lazycell.fill(Box::new(1)); in test_try_borrow_with_sound_with_reentrancy()
527 reference = lazycell.borrow().map(|r| &**r); in test_try_borrow_with_sound_with_reentrancy()
534 let mut lazycell = LazyCell::new(); in test_try_borrow_mut_with_ok() localVariable
536 let result = lazycell.try_borrow_mut_with::<(), _>(|| Ok(1)); in test_try_borrow_mut_with_ok()
540 assert_eq!(&mut 2, lazycell.borrow().unwrap()); in test_try_borrow_mut_with_ok()
545 let mut lazycell = LazyCell::<()>::new(); in test_try_borrow_mut_with_err() localVariable
546 let result = lazycell.try_borrow_mut_with(|| Err(1)); in test_try_borrow_mut_with_err()
552 let mut lazycell = LazyCell::new(); in test_try_borrow_mut_with_already_filled() localVariable
553 lazycell.fill(1).unwrap(); in test_try_borrow_mut_with_already_filled()
554 let result = lazycell.try_borrow_mut_with::<(), _>(|| unreachable!()); in test_try_borrow_mut_with_already_filled()
560 let lazycell = LazyCell::new(); in test_into_inner() localVariable
562 lazycell.fill(1).unwrap(); in test_into_inner()
563 let value = lazycell.into_inner(); in test_into_inner()
569 let lazycell: AtomicLazyCell<usize> = AtomicLazyCell::new(); in test_atomic_borrow_from_empty() localVariable
571 let value = lazycell.borrow(); in test_atomic_borrow_from_empty()
574 let value = lazycell.get(); in test_atomic_borrow_from_empty()
580 let lazycell = AtomicLazyCell::new(); in test_atomic_fill_and_borrow() localVariable
582 assert!(!lazycell.filled()); in test_atomic_fill_and_borrow()
583 lazycell.fill(1).unwrap(); in test_atomic_fill_and_borrow()
584 assert!(lazycell.filled()); in test_atomic_fill_and_borrow()
586 let value = lazycell.borrow(); in test_atomic_fill_and_borrow()
589 let value = lazycell.get(); in test_atomic_fill_and_borrow()
595 let lazycell = AtomicLazyCell::new(); in test_atomic_already_filled_panic() localVariable
597 lazycell.fill(1).unwrap(); in test_atomic_already_filled_panic()
598 assert_eq!(1, lazycell.fill(1).unwrap_err()); in test_atomic_already_filled_panic()
603 let lazycell = AtomicLazyCell::new(); in test_atomic_into_inner() localVariable
605 lazycell.fill(1).unwrap(); in test_atomic_into_inner()
606 let value = lazycell.into_inner(); in test_atomic_into_inner()