Skip to content

Commit

Permalink
[Cider] replace OnceLock with LazyLock (#2390)
Browse files Browse the repository at this point in the history
Tiny patch to replace `OnceLock` since `LazyLock` works in this case and
is slightly simpler
  • Loading branch information
EclecticGriffin authored Jan 6, 2025
1 parent 687fbb3 commit cbf9be0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cider/src/debugger/commands/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,16 +439,11 @@ impl Command {

// I wouldn't recommend looking at this

use std::sync::OnceLock;
use std::sync::LazyLock;
/// A (lazy) static list of [CommandInfo] objects used for the help and
/// explain messages. Access via [get_command_info]
static COMMAND_INFO: OnceLock<Box<[CommandInfo]>> = OnceLock::new();

/// Returns the list of [CommandInfo] objects used for the help and explain
/// messages
fn get_command_info() -> &'static [CommandInfo] {
COMMAND_INFO.get_or_init(|| {
[
static COMMAND_INFO: LazyLock<Box<[CommandInfo]>> = LazyLock::new(|| {
[
// step
CIBuilder::new().invocation("step")
.invocation("s")
Expand Down Expand Up @@ -538,7 +533,13 @@ fn get_command_info() -> &'static [CommandInfo] {
.invocation("quit")
.description("Exit the debugger").build(),
].into()
})
});

/// Returns the list of [CommandInfo] objects used for the help and explain
/// messages
#[inline]
fn get_command_info() -> &'static [CommandInfo] {
&COMMAND_INFO
}

#[derive(Clone, Debug)]
Expand Down

0 comments on commit cbf9be0

Please sign in to comment.