From 857d1c73067822dcd427e3d3b3541e0c8ad199f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20L=C3=B6bel?= Date: Mon, 20 Nov 2017 11:04:58 +0100 Subject: [PATCH 1/2] Make the 1.0 release --- Cargo.toml | 2 +- README.md | 2 +- src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 477c1ae..ee6032f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lazy_static" # NB: When modifying, also modify html_root_url in lib.rs -version = "0.2.11" +version = "1.0.0" authors = ["Marvin Löbel "] license = "MIT/Apache-2.0" diff --git a/README.md b/README.md index ad5380e..2cd30d0 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add the following dependency to your Cargo manifest... ```toml [dependencies] -lazy_static = "0.2" +lazy_static = "1.0" ``` ...and see the [docs](https://docs.rs/lazy_static) for how to use it. diff --git a/src/lib.rs b/src/lib.rs index bb15478..75976f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,7 +93,7 @@ The `Deref` implementation uses a hidden static variable that is guarded by a at #![cfg_attr(feature="spin_no_std", feature(const_fn))] #![cfg_attr(feature="nightly", feature(unreachable))] -#![doc(html_root_url = "https://docs.rs/lazy_static/0.2.11")] +#![doc(html_root_url = "https://docs.rs/lazy_static/1.0.0")] #![no_std] #[cfg(not(feature="nightly"))] From ad4ad8ecc0f0033e3f324ac2cd9a5dc6b8d020fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20L=C3=B6bel?= Date: Tue, 21 Nov 2017 00:05:59 +0100 Subject: [PATCH 2/2] Document the two relevant cargo features --- Cargo.toml | 4 ++-- src/core_lazy.rs | 1 + src/lazy.rs | 1 + src/lib.rs | 12 +++++++++++- src/nightly_lazy.rs | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ee6032f..eba4bd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ compiletest = ["compiletest_rs"] appveyor = { repository = "rust-lang-nursery/lazy-static.rs" } travis-ci = { repository = "rust-lang-nursery/lazy-static.rs" } -# is-it-maintained-issue-resolution = { repository = "rust-lang-nursery/lazy-static.rs" } -# is-it-maintained-open-issues = { repository = "rust-lang-nursery/lazy-static.rs" } +is-it-maintained-issue-resolution = { repository = "rust-lang-nursery/lazy-static.rs" } +is-it-maintained-open-issues = { repository = "rust-lang-nursery/lazy-static.rs" } maintenance = { status = "passively-maintained" } diff --git a/src/core_lazy.rs b/src/core_lazy.rs index 90c7aaa..ba496a6 100644 --- a/src/core_lazy.rs +++ b/src/core_lazy.rs @@ -26,6 +26,7 @@ impl Lazy { } #[macro_export] +#[doc(hidden)] macro_rules! __lazy_static_create { ($NAME:ident, $T:ty) => { static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::new(); diff --git a/src/lazy.rs b/src/lazy.rs index aab1e05..6fd4907 100644 --- a/src/lazy.rs +++ b/src/lazy.rs @@ -32,6 +32,7 @@ impl Lazy { unsafe impl Sync for Lazy {} #[macro_export] +#[doc(hidden)] macro_rules! __lazy_static_create { ($NAME:ident, $T:ty) => { static mut $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy(0 as *const $T, $crate::lazy::ONCE_INIT); diff --git a/src/lib.rs b/src/lib.rs index 75976f8..2e36821 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -86,7 +86,17 @@ fn main() { # Implementation details -The `Deref` implementation uses a hidden static variable that is guarded by a atomic check on each access. On stable Rust, the macro may need to allocate each static on the heap. +The `Deref` implementation uses a hidden static variable that is guarded by a atomic check on each access. + +# Cargo features + +This crate provides two cargo features: + +- `nightly`: This uses unstable language features only available on the nightly release channel for a more optimal implementation. In practice this currently means avoiding a heap allocation per static. This feature might get deprecated at a later point once all relevant optimizations are usable from stable. +- `spin_no_std` (implies `nightly`): This allows using this crate in a no-std environment, by depending on the standalone `spin` crate. + +Both features depend on unstable language features, which means +no guarantees can be made about them in regard to SemVer stability. */ diff --git a/src/nightly_lazy.rs b/src/nightly_lazy.rs index 0ad0f66..723222a 100644 --- a/src/nightly_lazy.rs +++ b/src/nightly_lazy.rs @@ -36,6 +36,7 @@ impl Lazy { unsafe impl Sync for Lazy {} #[macro_export] +#[doc(hidden)] macro_rules! __lazy_static_create { ($NAME:ident, $T:ty) => { static mut $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy(None, $crate::lazy::ONCE_INIT);