//! Safely use (stack) references outside their original scope.
// Debug cleanup. Uncomment before committing.
//! # Example
//!
//! ```rust
//! use ref_portals::rc::Anchor;
//!
//! let x = "Scoped".to_owned();
//! let anchor = Anchor::new(&x);
//! let self_owned: Box<dyn Fn() + 'static> = Box::new({
//! let portal = anchor.portal();
//! move || println!("{}", *portal)
//! });
//!
//! self_owned(); // Scoped
//! ```
//!
//! Note that dropping `anchor` before `self_owned` would still cause a panic here.
//! You can use weak portals to work around this:
//!
//! ```rust
//! use ref_portals::rc::Anchor;
//!
//! let x = "Scoped".to_owned();
//! let anchor = Anchor::new(&x);
//! let eternal: &'static dyn Fn() = Box::leak(Box::new({
//! let weak_portal = anchor.weak_portal();
//! move || println!(
//! "{}",
//! *weak_portal.upgrade(), // Panics iff the anchor has been dropped.
//! )
//! }));
//!
//! eternal(); // Scoped
//! ```
//!
//! # Notes
//!
//! Panic assertions in this documentation use [assert_panic](https://crates.io/crates/assert-panic).
/// Panicked when upgrading weak portals iff the anchor has been destroyed already.
const ANCHOR_DROPPED: &str = "Anchor dropped";
/// Panicked when borrowing through a portal or dropping an anchor if the anchor has been poisoned.
/// Only mutable anchors can be poisoned.
const ANCHOR_POISONED: &str = "Anchor poisoned";
/// Panicked when dropping an anchor if any (strong) portals still exist.
const ANCHOR_STILL_IN_USE: &str = "Anchor still in use (at least one portal exists)";