Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static_mut_ref warning #50

Merged
merged 1 commit into from
Jan 10, 2024
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