summaryrefslogtreecommitdiffstats
path: root/vendor/lazy_static
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/lazy_static
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/lazy_static')
-rw-r--r--vendor/lazy_static/.cargo-checksum.json1
-rw-r--r--vendor/lazy_static/Cargo.toml46
-rw-r--r--vendor/lazy_static/LICENSE-APACHE201
-rw-r--r--vendor/lazy_static/LICENSE-MIT25
-rw-r--r--vendor/lazy_static/README.md79
-rw-r--r--vendor/lazy_static/src/core_lazy.rs31
-rw-r--r--vendor/lazy_static/src/inline_lazy.rs57
-rw-r--r--vendor/lazy_static/src/lib.rs215
-rw-r--r--vendor/lazy_static/tests/no_std.rs20
-rw-r--r--vendor/lazy_static/tests/test.rs164
10 files changed, 839 insertions, 0 deletions
diff --git a/vendor/lazy_static/.cargo-checksum.json b/vendor/lazy_static/.cargo-checksum.json
new file mode 100644
index 000000000..fa241ed8f
--- /dev/null
+++ b/vendor/lazy_static/.cargo-checksum.json
@@ -0,0 +1 @@
+{"files":{"Cargo.toml":"05e37a4e63dc4a495998bb5133252a51d671c4e99061a6342089ed6eab43978a","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0621878e61f0d0fda054bcbe02df75192c28bde1ecc8289cbd86aeba2dd72720","README.md":"e2effacb5bbd7c01523f9a9e4a6a59c0f9b8698753b210fec5742408498197df","src/core_lazy.rs":"6b9fb6a4f553058e240756125b6b9ca43a83ed1fb72964343038ea0ea2e1af10","src/inline_lazy.rs":"f6184afbca4b477616f270790edc180263be806aa92ef0a9de681b4aac9e88c4","src/lib.rs":"99096a5d3089c0d86646f0805d1455befe2cb09683704af29c5c9d99ecab2683","tests/no_std.rs":"d68b149ee51ef5ae2b2906c0c94f5a9812d3b02811b13365c5a35e2ef90d25cf","tests/test.rs":"b3f7d805375dc5af7a2aa4b869944ad2ab4fc982b35ad718ea58f6914dc0a698"},"package":"e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"} \ No newline at end of file
diff --git a/vendor/lazy_static/Cargo.toml b/vendor/lazy_static/Cargo.toml
new file mode 100644
index 000000000..7f930c5e3
--- /dev/null
+++ b/vendor/lazy_static/Cargo.toml
@@ -0,0 +1,46 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+name = "lazy_static"
+version = "1.4.0"
+authors = ["Marvin Löbel <loebel.marvin@gmail.com>"]
+exclude = ["/.travis.yml", "/appveyor.yml"]
+description = "A macro for declaring lazily evaluated statics in Rust."
+documentation = "https://docs.rs/lazy_static"
+readme = "README.md"
+keywords = ["macro", "lazy", "static"]
+categories = ["no-std", "rust-patterns", "memory-management"]
+license = "MIT/Apache-2.0"
+repository = "https://github.com/rust-lang-nursery/lazy-static.rs"
+[dependencies.spin]
+version = "0.5.0"
+optional = true
+[dev-dependencies.doc-comment]
+version = "0.3.1"
+
+[features]
+spin_no_std = ["spin"]
+[badges.appveyor]
+repository = "rust-lang-nursery/lazy-static.rs"
+
+[badges.is-it-maintained-issue-resolution]
+repository = "rust-lang-nursery/lazy-static.rs"
+
+[badges.is-it-maintained-open-issues]
+repository = "rust-lang-nursery/lazy-static.rs"
+
+[badges.maintenance]
+status = "passively-maintained"
+
+[badges.travis-ci]
+repository = "rust-lang-nursery/lazy-static.rs"
diff --git a/vendor/lazy_static/LICENSE-APACHE b/vendor/lazy_static/LICENSE-APACHE
new file mode 100644
index 000000000..16fe87b06
--- /dev/null
+++ b/vendor/lazy_static/LICENSE-APACHE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/vendor/lazy_static/LICENSE-MIT b/vendor/lazy_static/LICENSE-MIT
new file mode 100644
index 000000000..25597d583
--- /dev/null
+++ b/vendor/lazy_static/LICENSE-MIT
@@ -0,0 +1,25 @@
+Copyright (c) 2010 The Rust Project Developers
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/vendor/lazy_static/README.md b/vendor/lazy_static/README.md
new file mode 100644
index 000000000..aa9f82832
--- /dev/null
+++ b/vendor/lazy_static/README.md
@@ -0,0 +1,79 @@
+lazy-static.rs
+==============
+
+A macro for declaring lazily evaluated statics in Rust.
+
+Using this macro, it is possible to have `static`s that require code to be
+executed at runtime in order to be initialized.
+This includes anything requiring heap allocations, like vectors or hash maps,
+as well as anything that requires non-const function calls to be computed.
+
+[![Travis-CI Status](https://travis-ci.com/rust-lang-nursery/lazy-static.rs.svg?branch=master)](https://travis-ci.com/rust-lang-nursery/lazy-static.rs)
+[![Latest version](https://img.shields.io/crates/v/lazy_static.svg)](https://crates.io/crates/lazy_static)
+[![Documentation](https://docs.rs/lazy_static/badge.svg)](https://docs.rs/lazy_static)
+[![License](https://img.shields.io/crates/l/lazy_static.svg)](https://github.com/rust-lang-nursery/lazy-static.rs#license)
+
+## Minimum supported `rustc`
+
+`1.27.2+`
+
+This version is explicitly tested in CI and may only be bumped in new minor versions. Any changes to the supported minimum version will be called out in the release notes.
+
+
+# Getting Started
+
+[lazy-static.rs is available on crates.io](https://crates.io/crates/lazy_static).
+It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.
+
+At the point of the last update of this README, the latest published version could be used like this:
+
+Add the following dependency to your Cargo manifest...
+
+```toml
+[dependencies]
+lazy_static = "1.4.0"
+```
+
+...and see the [docs](https://docs.rs/lazy_static) for how to use it.
+
+# Example
+
+```rust
+#[macro_use]
+extern crate lazy_static;
+
+use std::collections::HashMap;
+
+lazy_static! {
+ static ref HASHMAP: HashMap<u32, &'static str> = {
+ let mut m = HashMap::new();
+ m.insert(0, "foo");
+ m.insert(1, "bar");
+ m.insert(2, "baz");
+ m
+ };
+}
+
+fn main() {
+ // First access to `HASHMAP` initializes it
+ println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap());
+
+ // Any further access to `HASHMAP` just returns the computed value
+ println!("The entry for `1` is \"{}\".", HASHMAP.get(&1).unwrap());
+}
+```
+
+## License
+
+Licensed under either of
+
+ * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
+ * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
+
+at your option.
+
+### Contribution
+
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
+additional terms or conditions.
diff --git a/vendor/lazy_static/src/core_lazy.rs b/vendor/lazy_static/src/core_lazy.rs
new file mode 100644
index 000000000..b66c3e0d0
--- /dev/null
+++ b/vendor/lazy_static/src/core_lazy.rs
@@ -0,0 +1,31 @@
+// Copyright 2016 lazy-static.rs Developers
+//
+// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
+// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
+// http://opensource.org/licenses/MIT>, at your option. This file may not be
+// copied, modified, or distributed except according to those terms.
+
+extern crate spin;
+
+use self::spin::Once;
+
+pub struct Lazy<T: Sync>(Once<T>);
+
+impl<T: Sync> Lazy<T> {
+ pub const INIT: Self = Lazy(Once::INIT);
+
+ #[inline(always)]
+ pub fn get<F>(&'static self, builder: F) -> &T
+ where F: FnOnce() -> T
+ {
+ self.0.call_once(builder)
+ }
+}
+
+#[macro_export]
+#[doc(hidden)]
+macro_rules! __lazy_static_create {
+ ($NAME:ident, $T:ty) => {
+ static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT;
+ }
+}
diff --git a/vendor/lazy_static/src/inline_lazy.rs b/vendor/lazy_static/src/inline_lazy.rs
new file mode 100644
index 000000000..219ce9c60
--- /dev/null
+++ b/vendor/lazy_static/src/inline_lazy.rs
@@ -0,0 +1,57 @@
+// Copyright 2016 lazy-static.rs Developers
+//
+// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
+// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
+// http://opensource.org/licenses/MIT>, at your option. This file may not be
+// copied, modified, or distributed except according to those terms.
+
+extern crate core;
+extern crate std;
+
+use self::std::prelude::v1::*;
+use self::std::cell::Cell;
+use self::std::hint::unreachable_unchecked;
+use self::std::sync::Once;
+#[allow(deprecated)]
+pub use self::std::sync::ONCE_INIT;
+
+// FIXME: Replace Option<T> with MaybeUninit<T> (stable since 1.36.0)
+pub struct Lazy<T: Sync>(Cell<Option<T>>, Once);
+
+impl<T: Sync> Lazy<T> {
+ #[allow(deprecated)]
+ pub const INIT: Self = Lazy(Cell::new(None), ONCE_INIT);
+
+ #[inline(always)]
+ pub fn get<F>(&'static self, f: F) -> &T
+ where
+ F: FnOnce() -> T,
+ {
+ self.1.call_once(|| {
+ self.0.set(Some(f()));
+ });
+
+ // `self.0` is guaranteed to be `Some` by this point
+ // The `Once` will catch and propagate panics
+ unsafe {
+ match *self.0.as_ptr() {
+ Some(ref x) => x,
+ None => {
+ debug_assert!(false, "attempted to derefence an uninitialized lazy static. This is a bug");
+
+ unreachable_unchecked()
+ },
+ }
+ }
+ }
+}
+
+unsafe impl<T: Sync> Sync for Lazy<T> {}
+
+#[macro_export]
+#[doc(hidden)]
+macro_rules! __lazy_static_create {
+ ($NAME:ident, $T:ty) => {
+ static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT;
+ };
+}
diff --git a/vendor/lazy_static/src/lib.rs b/vendor/lazy_static/src/lib.rs
new file mode 100644
index 000000000..cada0dc68
--- /dev/null
+++ b/vendor/lazy_static/src/lib.rs
@@ -0,0 +1,215 @@
+// Copyright 2016 lazy-static.rs Developers
+//
+// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
+// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
+// http://opensource.org/licenses/MIT>, at your option. This file may not be
+// copied, modified, or distributed except according to those terms.
+
+/*!
+A macro for declaring lazily evaluated statics.
+
+Using this macro, it is possible to have `static`s that require code to be
+executed at runtime in order to be initialized.
+This includes anything requiring heap allocations, like vectors or hash maps,
+as well as anything that requires function calls to be computed.
+
+# Syntax
+
+```ignore
+lazy_static! {
+ [pub] static ref NAME_1: TYPE_1 = EXPR_1;
+ [pub] static ref NAME_2: TYPE_2 = EXPR_2;
+ ...
+ [pub] static ref NAME_N: TYPE_N = EXPR_N;
+}
+```
+
+Attributes (including doc comments) are supported as well:
+
+```rust
+# #[macro_use]
+# extern crate lazy_static;
+# fn main() {
+lazy_static! {
+ /// This is an example for using doc comment attributes
+ static ref EXAMPLE: u8 = 42;
+}
+# }
+```
+
+# Semantics
+
+For a given `static ref NAME: TYPE = EXPR;`, the macro generates a unique type that
+implements `Deref<TYPE>` and stores it in a static with name `NAME`. (Attributes end up
+attaching to this type.)
+
+On first deref, `EXPR` gets evaluated and stored internally, such that all further derefs
+can return a reference to the same object. Note that this can lead to deadlocks
+if you have multiple lazy statics that depend on each other in their initialization.
+
+Apart from the lazy initialization, the resulting "static ref" variables
+have generally the same properties as regular "static" variables:
+
+- Any type in them needs to fulfill the `Sync` trait.
+- If the type has a destructor, then it will not run when the process exits.
+
+# Example
+
+Using the macro:
+
+```rust
+#[macro_use]
+extern crate lazy_static;
+
+use std::collections::HashMap;
+
+lazy_static! {
+ static ref HASHMAP: HashMap<u32, &'static str> = {
+ let mut m = HashMap::new();
+ m.insert(0, "foo");
+ m.insert(1, "bar");
+ m.insert(2, "baz");
+ m
+ };
+ static ref COUNT: usize = HASHMAP.len();
+ static ref NUMBER: u32 = times_two(21);
+}
+
+fn times_two(n: u32) -> u32 { n * 2 }
+
+fn main() {
+ println!("The map has {} entries.", *COUNT);
+ println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap());
+ println!("A expensive calculation on a static results in: {}.", *NUMBER);
+}
+```
+
+# Implementation details
+
+The `Deref` implementation uses a hidden static variable that is guarded by an atomic check on each access.
+
+# Cargo features
+
+This crate provides one cargo feature:
+
+- `spin_no_std`: This allows using this crate in a no-std environment, by depending on the standalone `spin` crate.
+
+*/
+
+#![doc(html_root_url = "https://docs.rs/lazy_static/1.4.0")]
+#![no_std]
+
+#[cfg(not(feature = "spin_no_std"))]
+#[path="inline_lazy.rs"]
+#[doc(hidden)]
+pub mod lazy;
+
+#[cfg(test)]
+#[macro_use]
+extern crate doc_comment;
+
+#[cfg(test)]
+doctest!("../README.md");
+
+#[cfg(feature = "spin_no_std")]
+#[path="core_lazy.rs"]
+#[doc(hidden)]
+pub mod lazy;
+
+#[doc(hidden)]
+pub use core::ops::Deref as __Deref;
+
+#[macro_export(local_inner_macros)]
+#[doc(hidden)]
+macro_rules! __lazy_static_internal {
+ // optional visibility restrictions are wrapped in `()` to allow for
+ // explicitly passing otherwise implicit information about private items
+ ($(#[$attr:meta])* ($($vis:tt)*) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
+ __lazy_static_internal!(@MAKE TY, $(#[$attr])*, ($($vis)*), $N);
+ __lazy_static_internal!(@TAIL, $N : $T = $e);
+ lazy_static!($($t)*);
+ };
+ (@TAIL, $N:ident : $T:ty = $e:expr) => {
+ impl $crate::__Deref for $N {
+ type Target = $T;
+ fn deref(&self) -> &$T {
+ #[inline(always)]
+ fn __static_ref_initialize() -> $T { $e }
+
+ #[inline(always)]
+ fn __stability() -> &'static $T {
+ __lazy_static_create!(LAZY, $T);
+ LAZY.get(__static_ref_initialize)
+ }
+ __stability()
+ }
+ }
+ impl $crate::LazyStatic for $N {
+ fn initialize(lazy: &Self) {
+ let _ = &**lazy;
+ }
+ }
+ };
+ // `vis` is wrapped in `()` to prevent parsing ambiguity
+ (@MAKE TY, $(#[$attr:meta])*, ($($vis:tt)*), $N:ident) => {
+ #[allow(missing_copy_implementations)]
+ #[allow(non_camel_case_types)]
+ #[allow(dead_code)]
+ $(#[$attr])*
+ $($vis)* struct $N {__private_field: ()}
+ #[doc(hidden)]
+ $($vis)* static $N: $N = $N {__private_field: ()};
+ };
+ () => ()
+}
+
+#[macro_export(local_inner_macros)]
+macro_rules! lazy_static {
+ ($(#[$attr:meta])* static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
+ // use `()` to explicitly forward the information about private items
+ __lazy_static_internal!($(#[$attr])* () static ref $N : $T = $e; $($t)*);
+ };
+ ($(#[$attr:meta])* pub static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
+ __lazy_static_internal!($(#[$attr])* (pub) static ref $N : $T = $e; $($t)*);
+ };
+ ($(#[$attr:meta])* pub ($($vis:tt)+) static ref $N:ident : $T:ty = $e:expr; $($t:tt)*) => {
+ __lazy_static_internal!($(#[$attr])* (pub ($($vis)+)) static ref $N : $T = $e; $($t)*);
+ };
+ () => ()
+}
+
+/// Support trait for enabling a few common operation on lazy static values.
+///
+/// This is implemented by each defined lazy static, and
+/// used by the free functions in this crate.
+pub trait LazyStatic {
+ #[doc(hidden)]
+ fn initialize(lazy: &Self);
+}
+
+/// Takes a shared reference to a lazy static and initializes
+/// it if it has not been already.
+///
+/// This can be used to control the initialization point of a lazy static.
+///
+/// Example:
+///
+/// ```rust
+/// #[macro_use]
+/// extern crate lazy_static;
+///
+/// lazy_static! {
+/// static ref BUFFER: Vec<u8> = (0..255).collect();
+/// }
+///
+/// fn main() {
+/// lazy_static::initialize(&BUFFER);
+///
+/// // ...
+/// work_with_initialized_data(&BUFFER);
+/// }
+/// # fn work_with_initialized_data(_: &[u8]) {}
+/// ```
+pub fn initialize<T: LazyStatic>(lazy: &T) {
+ LazyStatic::initialize(lazy);
+}
diff --git a/vendor/lazy_static/tests/no_std.rs b/vendor/lazy_static/tests/no_std.rs
new file mode 100644
index 000000000..f94a1aaa6
--- /dev/null
+++ b/vendor/lazy_static/tests/no_std.rs
@@ -0,0 +1,20 @@
+#![cfg(feature="spin_no_std")]
+
+#![no_std]
+
+#[macro_use]
+extern crate lazy_static;
+
+lazy_static! {
+ /// Documentation!
+ pub static ref NUMBER: u32 = times_two(3);
+}
+
+fn times_two(n: u32) -> u32 {
+ n * 2
+}
+
+#[test]
+fn test_basic() {
+ assert_eq!(*NUMBER, 6);
+}
diff --git a/vendor/lazy_static/tests/test.rs b/vendor/lazy_static/tests/test.rs
new file mode 100644
index 000000000..03d0ab683
--- /dev/null
+++ b/vendor/lazy_static/tests/test.rs
@@ -0,0 +1,164 @@
+#[macro_use]
+extern crate lazy_static;
+use std::collections::HashMap;
+
+lazy_static! {
+ /// Documentation!
+ pub static ref NUMBER: u32 = times_two(3);
+
+ static ref ARRAY_BOXES: [Box<u32>; 3] = [Box::new(1), Box::new(2), Box::new(3)];
+
+ /// More documentation!
+ #[allow(unused_variables)]
+ #[derive(Copy, Clone, Debug)]
+ pub static ref STRING: String = "hello".to_string();
+
+ static ref HASHMAP: HashMap<u32, &'static str> = {
+ let mut m = HashMap::new();
+ m.insert(0, "abc");
+ m.insert(1, "def");
+ m.insert(2, "ghi");
+ m
+ };
+
+ // This should not compile if the unsafe is removed.
+ static ref UNSAFE: u32 = unsafe {
+ std::mem::transmute::<i32, u32>(-1)
+ };
+}
+
+lazy_static! {
+ static ref S1: &'static str = "a";
+ static ref S2: &'static str = "b";
+}
+lazy_static! {
+ static ref S3: String = [*S1, *S2].join("");
+}
+
+#[test]
+fn s3() {
+ assert_eq!(&*S3, "ab");
+}
+
+fn times_two(n: u32) -> u32 {
+ n * 2
+}
+
+#[test]
+fn test_basic() {
+ assert_eq!(&**STRING, "hello");
+ assert_eq!(*NUMBER, 6);
+ assert!(HASHMAP.get(&1).is_some());
+ assert!(HASHMAP.get(&3).is_none());
+ assert_eq!(&*ARRAY_BOXES, &[Box::new(1), Box::new(2), Box::new(3)]);
+ assert_eq!(*UNSAFE, std::u32::MAX);
+}
+
+#[test]
+fn test_repeat() {
+ assert_eq!(*NUMBER, 6);
+ assert_eq!(*NUMBER, 6);
+ assert_eq!(*NUMBER, 6);
+}
+
+#[test]
+fn test_meta() {
+ // this would not compile if STRING were not marked #[derive(Copy, Clone)]
+ let copy_of_string = STRING;
+ // just to make sure it was copied
+ assert!(&STRING as *const _ != &copy_of_string as *const _);
+
+ // this would not compile if STRING were not marked #[derive(Debug)]
+ assert_eq!(format!("{:?}", STRING), "STRING { __private_field: () }".to_string());
+}
+
+mod visibility {
+ lazy_static! {
+ pub static ref FOO: Box<u32> = Box::new(0);
+ static ref BAR: Box<u32> = Box::new(98);
+ }
+
+ pub mod inner {
+ lazy_static! {
+ pub(in visibility) static ref BAZ: Box<u32> = Box::new(42);
+ pub(crate) static ref BAG: Box<u32> = Box::new(37);
+ }
+ }
+
+ #[test]
+ fn sub_test() {
+ assert_eq!(**FOO, 0);
+ assert_eq!(**BAR, 98);
+ assert_eq!(**inner::BAZ, 42);
+ assert_eq!(**inner::BAG, 37);
+ }
+}
+
+#[test]
+fn test_visibility() {
+ assert_eq!(*visibility::FOO, Box::new(0));
+ assert_eq!(*visibility::inner::BAG, Box::new(37));
+}
+
+// This should not cause a warning about a missing Copy implementation
+lazy_static! {
+ pub static ref VAR: i32 = { 0 };
+}
+
+#[derive(Copy, Clone, Debug, PartialEq)]
+struct X;
+struct Once(X);
+const ONCE_INIT: Once = Once(X);
+static DATA: X = X;
+static ONCE: X = X;
+fn require_sync() -> X { X }
+fn transmute() -> X { X }
+fn __static_ref_initialize() -> X { X }
+fn test(_: Vec<X>) -> X { X }
+
+// All these names should not be shadowed
+lazy_static! {
+ static ref ITEM_NAME_TEST: X = {
+ test(vec![X, Once(X).0, ONCE_INIT.0, DATA, ONCE,
+ require_sync(), transmute(),
+ // Except this, which will sadly be shadowed by internals:
+ // __static_ref_initialize()
+ ])
+ };
+}
+
+#[test]
+fn item_name_shadowing() {
+ assert_eq!(*ITEM_NAME_TEST, X);
+}
+
+use std::sync::atomic::AtomicBool;
+#[allow(deprecated)]
+use std::sync::atomic::ATOMIC_BOOL_INIT;
+use std::sync::atomic::Ordering::SeqCst;
+
+#[allow(deprecated)]
+static PRE_INIT_FLAG: AtomicBool = ATOMIC_BOOL_INIT;
+
+lazy_static! {
+ static ref PRE_INIT: () = {
+ PRE_INIT_FLAG.store(true, SeqCst);
+ ()
+ };
+}
+
+#[test]
+fn pre_init() {
+ assert_eq!(PRE_INIT_FLAG.load(SeqCst), false);
+ lazy_static::initialize(&PRE_INIT);
+ assert_eq!(PRE_INIT_FLAG.load(SeqCst), true);
+}
+
+lazy_static! {
+ static ref LIFETIME_NAME: for<'a> fn(&'a u8) = { fn f(_: &u8) {} f };
+}
+
+#[test]
+fn lifetime_name() {
+ let _ = LIFETIME_NAME;
+}