Skip to content

Commit

Permalink
Fixed LateInit example stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-cooper committed Dec 23, 2022
1 parent ba8b9fe commit 3f750e1
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@
//!
//!
//! ```
//! use std::fmt;
//!
//! use once_cell::sync::OnceCell;
//!
//! #[derive(Debug)]
Expand All @@ -228,16 +230,28 @@
//! }
//! }
//!
//! #[derive(Default, Debug)]
//! #[derive(Default)]
//! struct A<'a> {
//! b: LateInit<&'a B<'a>>,
//! }
//!
//! #[derive(Default, Debug)]
//! #[derive(Default)]
//! struct B<'a> {
//! a: LateInit<&'a A<'a>>
//! }
//!
//! impl fmt::Debug for A<'_> {
//! fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
//! write!(f, "A")
//! }
//! }
//!
//! impl fmt::Debug for B<'_> {
//! fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
//! write!(f, "B")
//! }
//! }
//!
//! fn build_cycle() {
//! let a = A::default();
//! let b = B::default();
Expand Down Expand Up @@ -314,9 +328,9 @@
//! **Does this crate support async?**
//!
//! No, but you can use [`async_once_cell`](https://crates.io/crates/async_once_cell) instead.
//!
//!
//! **Can I bring my own mutex?**
//!
//!
//! There is [generic_once_cell](https://crates.io/crates/generic_once_cell) to allow just that.
//!
//! # Related crates
Expand Down

0 comments on commit 3f750e1

Please sign in to comment.