From 66397e6abc5ecea4dcc5af3c34e76d99441972b7 Mon Sep 17 00:00:00 2001 From: Nathan Fiedler Date: Thu, 31 Oct 2019 08:45:46 -0700 Subject: [PATCH] Fix deprecated usage of ONCE_INIT Once::new() was added in Rust 1.2.0 and ONCE_INIT has been deprecated as of Rust 1.38. Also updated the README example. cargo test passes --- README.md | 4 ++-- tests/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 880fa2e..030f2b2 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,11 @@ MagickWand has some global state that needs to be initialized prior to using the ```rust use magick_rust::{MagickWand, magick_wand_genesis}; -use std::sync::{Once, ONCE_INIT}; +use std::sync::Once; // Used to make sure MagickWand is initialized exactly once. Note that we // do not bother shutting down, we simply exit when we're done. -static START: Once = ONCE_INIT; +static START: Once = Once::new(); fn resize() -> Result, &'static str> { START.call_once(|| { diff --git a/tests/lib.rs b/tests/lib.rs index 6541daf..7e459c6 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -23,11 +23,11 @@ use std::error::Error; use std::fs::File; use std::io::Read; use std::path::Path; -use std::sync::{Once, ONCE_INIT}; +use std::sync::Once; // Used to make sure MagickWand is initialized exactly once. Note that we // do not bother shutting down, we simply exit when the tests are done. -static START: Once = ONCE_INIT; +static START: Once = Once::new(); #[test] fn test_new_drop() {