From 5ca6ff5afc0e26260f6a9b0d8cfab51756e13a2c Mon Sep 17 00:00:00 2001 From: Brandon W Maister Date: Mon, 23 Dec 2019 13:26:05 -0500 Subject: [PATCH] Make it harder to accidentally use private features In particular if built with `--all-features` or `features = "all"` we don't want to accidentally make it look like `YearFlags` are something that people should use. So: hide it from docs and put it behind a dunder. --- Cargo.toml | 1 + benches/chrono.rs | 4 ++-- src/lib.rs | 10 ++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0b957f4..1734c88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ alloc = [] std = [] clock = ["time", "std"] wasmbind = ["wasm-bindgen", "js-sys"] +__internal_bench = [] [dependencies] time = { version = "0.1.39", optional = true } diff --git a/benches/chrono.rs b/benches/chrono.rs index 1bd66af..eede85c 100644 --- a/benches/chrono.rs +++ b/benches/chrono.rs @@ -6,7 +6,7 @@ extern crate criterion; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use chrono::prelude::*; -use chrono::{Utc, FixedOffset, DateTime, YearFlags}; +use chrono::{Utc, FixedOffset, DateTime, __BenchYearFlags}; fn bench_datetime_parse_from_rfc2822(c: &mut Criterion) { c.bench_function("bench_datetime_parse_from_rfc2822", |b| { @@ -56,7 +56,7 @@ fn bench_year_flags_from_year(c: &mut Criterion) { c.bench_function("bench_year_flags_from_year", |b| b.iter(|| { for year in -999i32..1000 { - YearFlags::from_year(year); + __BenchYearFlags::from_year(year); } })); } diff --git a/src/lib.rs b/src/lib.rs index 12d24f7..9d85371 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -477,10 +477,7 @@ pub mod naive { //! (e.g. [`TimeZone`](../offset/trait.TimeZone.html)), //! but can be also used for the simpler date and time handling. - #[cfg(not(feature = "__internal_bench"))] mod internals; - #[cfg(feature = "__internal_bench")] - pub mod internals; mod date; mod isoweek; mod time; @@ -494,6 +491,10 @@ pub mod naive { #[allow(deprecated)] pub use self::datetime::rustc_serialize::TsSeconds; + #[cfg(feature = "__internal_bench")] + #[doc(hidden)] + pub use self::internals::YearFlags as __BenchYearFlags; + /// Serialization/Deserialization of naive types in alternate formats /// @@ -514,7 +515,8 @@ pub mod format; mod round; #[cfg(feature = "__internal_bench")] -pub use naive::internals::YearFlags; +#[doc(hidden)] +pub use naive::__BenchYearFlags; /// Serialization/Deserialization in alternate formats ///