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
This commit is contained in:
Nathan Fiedler
2019-10-31 08:45:46 -07:00
parent 8e531f5611
commit 66397e6abc
2 changed files with 4 additions and 4 deletions

View File

@ -50,11 +50,11 @@ MagickWand has some global state that needs to be initialized prior to using the
```rust ```rust
use magick_rust::{MagickWand, magick_wand_genesis}; 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 // Used to make sure MagickWand is initialized exactly once. Note that we
// do not bother shutting down, we simply exit when we're done. // 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<Vec<u8>, &'static str> { fn resize() -> Result<Vec<u8>, &'static str> {
START.call_once(|| { START.call_once(|| {

View File

@ -23,11 +23,11 @@ use std::error::Error;
use std::fs::File; use std::fs::File;
use std::io::Read; use std::io::Read;
use std::path::Path; 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 // 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. // do not bother shutting down, we simply exit when the tests are done.
static START: Once = ONCE_INIT; static START: Once = Once::new();
#[test] #[test]
fn test_new_drop() { fn test_new_drop() {