Skip to content

Commit

Permalink
Use MaybeUninit::{assume_init_ref, write}
Browse files Browse the repository at this point in the history
Since msrv is bumped to 1.63

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Apr 18, 2024
1 parent 17453d9 commit a63906f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/parallel/job_token.rs
Expand Up @@ -34,6 +34,7 @@ impl JobTokenServer {
/// that has to be static so that it will be shared by all cc
/// compilation.
fn new() -> &'static Self {
// TODO: Replace with a OnceLock once MSRV is 1.70
static INIT: Once = Once::new();
static mut JOBSERVER: MaybeUninit<JobTokenServer> = MaybeUninit::uninit();

Expand All @@ -42,10 +43,9 @@ impl JobTokenServer {
let server = inherited_jobserver::JobServer::from_env()
.map(Self::Inherited)
.unwrap_or_else(|| Self::InProcess(inprocess_jobserver::JobServer::new()));
JOBSERVER = MaybeUninit::new(server);
JOBSERVER.write(server);
});
// TODO: Poor man's assume_init_ref, as that'd require a MSRV of 1.55.
&*JOBSERVER.as_ptr()
JOBSERVER.assume_init_ref()
}
}
}
Expand Down

0 comments on commit a63906f

Please sign in to comment.