title: Rust - Is `Lazy::new` guaranteed to be called only once even when running tests in parallel?
body: <p>I am testing some code that expects a postgres database with a particular set of data in the tables.  I have a function that will connect to a database, ensure the data is correct, then return a connection. Once this data is set up, all the queries are read-only, so I'm not worrying about synchronizing the rest of the tests.</p>
  <p>I'm worried about potential race conditions if this &quot;ensure the database is correct&quot; step is called twice at the same time.</p>
  <p>I've wrapped this setup function in a <code>once_cell::sync::Lazy</code>, to try to guarantee that it is called only once per <code>cargo test</code> invocation, but I'm not sure this is actually guaranteeing what I think it is.</p>
  <p>Note, this also includes doctests, which I understand are run with an entirely different model to regular unit tests. Does my use of <code>Lazy</code> still guarantee that the function is only run once, even in these circumstances?</p>
  <p>This feels like a relatively common problem, but I've had trouble finding better solutions on the internet so far.</p>