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.
This commit is contained in:
Brandon W Maister 2019-12-23 13:26:05 -05:00
parent 4f73f9423b
commit 5ca6ff5afc
3 changed files with 9 additions and 6 deletions

View File

@ -29,6 +29,7 @@ alloc = []
std = [] std = []
clock = ["time", "std"] clock = ["time", "std"]
wasmbind = ["wasm-bindgen", "js-sys"] wasmbind = ["wasm-bindgen", "js-sys"]
__internal_bench = []
[dependencies] [dependencies]
time = { version = "0.1.39", optional = true } time = { version = "0.1.39", optional = true }

View File

@ -6,7 +6,7 @@ extern crate criterion;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{black_box, criterion_group, criterion_main, Criterion};
use chrono::prelude::*; use chrono::prelude::*;
use chrono::{Utc, FixedOffset, DateTime, YearFlags}; use chrono::{Utc, FixedOffset, DateTime, __BenchYearFlags};
fn bench_datetime_parse_from_rfc2822(c: &mut Criterion) { fn bench_datetime_parse_from_rfc2822(c: &mut Criterion) {
c.bench_function("bench_datetime_parse_from_rfc2822", |b| { 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| c.bench_function("bench_year_flags_from_year", |b|
b.iter(|| { b.iter(|| {
for year in -999i32..1000 { for year in -999i32..1000 {
YearFlags::from_year(year); __BenchYearFlags::from_year(year);
} }
})); }));
} }

View File

@ -477,10 +477,7 @@ pub mod naive {
//! (e.g. [`TimeZone`](../offset/trait.TimeZone.html)), //! (e.g. [`TimeZone`](../offset/trait.TimeZone.html)),
//! but can be also used for the simpler date and time handling. //! but can be also used for the simpler date and time handling.
#[cfg(not(feature = "__internal_bench"))]
mod internals; mod internals;
#[cfg(feature = "__internal_bench")]
pub mod internals;
mod date; mod date;
mod isoweek; mod isoweek;
mod time; mod time;
@ -494,6 +491,10 @@ pub mod naive {
#[allow(deprecated)] #[allow(deprecated)]
pub use self::datetime::rustc_serialize::TsSeconds; 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 /// Serialization/Deserialization of naive types in alternate formats
/// ///
@ -514,7 +515,8 @@ pub mod format;
mod round; mod round;
#[cfg(feature = "__internal_bench")] #[cfg(feature = "__internal_bench")]
pub use naive::internals::YearFlags; #[doc(hidden)]
pub use naive::__BenchYearFlags;
/// Serialization/Deserialization in alternate formats /// Serialization/Deserialization in alternate formats
/// ///