Skip to content

Instantly share code, notes, and snippets.

@smallnest
Created September 27, 2019 02:38
Show Gist options
  • Select an option

  • Save smallnest/475daa698b2a34b27363f60e0aee02c4 to your computer and use it in GitHub Desktop.

Select an option

Save smallnest/475daa698b2a34b27363f60e0aee02c4 to your computer and use it in GitHub Desktop.
#[macro_use]
extern crate lazy_static;

use std::sync::Mutex;

lazy_static! {
    static ref ARRAY: Mutex<Vec<u8>> = Mutex::new(vec![]);
}

fn do_a_call() {
    ARRAY.lock().unwrap().push(1);
}

fn main() {
    do_a_call();
    do_a_call();
    do_a_call();

    println!("called {}", ARRAY.lock().unwrap().len());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment