Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/ignore.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
use crate::de::{Map, Seq, Visitor};
use crate::error::Result;
use alloc::boxed::Box;
use core::ptr;

impl dyn Visitor {
pub fn ignore() -> &'static mut dyn Visitor {
static mut IGNORE: Ignore = Ignore;
unsafe { &mut IGNORE }
//
// The following may be needed if stacked borrows gets more selective
// about the above in the future:
//
// unsafe { &mut *ptr::addr_of_mut!(IGNORE) }
//

// Conceptually we have an array of type [Ignore; ∞] in a static, which
// is zero sized, and each caller of `fn ignore` gets a unique one of
// them, as if by `&mut *ptr::addr_of_mut!(IGNORE[i++])` for some
// appropriately synchronized i.
unsafe { &mut *ptr::addr_of_mut!(IGNORE) }
}
}

Expand Down