Skip to content

Commit

Permalink
Replace lazy_static with OnceCell
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueTheDuck committed Sep 26, 2023
1 parent 08495c5 commit af33b1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ nds-sys = { path = "nds-sys" }
nds-proc-macros = { path = "nds-proc-macros", optional = true }
bitflags = "1.3.2"
paste = "1"
lazy_static = { version = "1.4", features = ["spin_no_std"], optional = true }
spin = { version = "0.9", default-features = false, features = [
"spin_mutex",
"portable_atomic",
], optional = true }
portable-atomic = { version = "1.4.2", default-features = false, features = [
"unsafe-assume-single-core",
"require-cas",
], optional = true }
embedded-graphics-core = { version = "0.3.3", optional = true }
once_cell = { version = "1.18.0", default-features = false, optional = true }

[features]
default = [
Expand All @@ -28,5 +33,5 @@ default = [
"embedded-graphics-core",
]
default_panic_screen = []
nocash_tty = ["spin", "lazy_static"]
nocash_tty = ["spin", "once_cell", "portable-atomic"]
proc_macros = ["nds-proc-macros"]
19 changes: 5 additions & 14 deletions src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use core::fmt::{Debug, Write};
#[cfg(feature = "nocash_tty")]
use lazy_static::lazy_static;
use nds_sys::debug::registers;
#[cfg(feature = "nocash_tty")]
use spin::Mutex;
extern crate alloc;
use core::arch::asm;

Expand Down Expand Up @@ -35,16 +31,11 @@ pub fn _print(args: core::fmt::Arguments) {
}

#[cfg(feature = "nocash_tty")]
lazy_static! {
/// Used to access all NO$GBA debugging functions.
/// The debugger is detected on startup, and if it is found,
/// [`NoCash::is_enabled`] will return `true`.
pub static ref NOCASH: Mutex<NoCash> = {
let mut nocash = NoCash { found: false };
nocash.find_debugger();
Mutex::new(nocash)
};
}
/// Used to access all NO$GBA debugging functions.
/// The debugger is detected on startup, and if it is found,
/// [`NoCash::is_enabled`] will return `true`.
pub static NOCASH: spin::Mutex<once_cell::unsync::Lazy<NoCash>> =
spin::Mutex::new(once_cell::unsync::Lazy::new(NoCash::new));

/// Symbolizes the emulator NO$GBA and provides
/// an API for its debugging capabilities.
Expand Down

0 comments on commit af33b1e

Please sign in to comment.