/rust/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.41/src/lib.rs
Line | Count | Source (jump to first uncovered line) |
1 | | //! # Feature flags |
2 | | //! |
3 | | //! This crate exposes a number of features. These can be enabled or disabled as shown |
4 | | //! [in Cargo's documentation](https://doc.rust-lang.org/cargo/reference/features.html). Features |
5 | | //! are _disabled_ by default unless otherwise noted. |
6 | | //! |
7 | | //! Reliance on a given feature is always indicated alongside the item definition. |
8 | | //! |
9 | | //! - `std` (_enabled by default, implicitly enables `alloc`_) |
10 | | //! |
11 | | //! This enables a number of features that depend on the standard library. |
12 | | //! |
13 | | //! - `alloc` (_enabled by default via `std`_) |
14 | | //! |
15 | | //! Enables a number of features that require the ability to dynamically allocate memory. |
16 | | //! |
17 | | //! - `macros` |
18 | | //! |
19 | | //! Enables macros that provide compile-time verification of values and intuitive syntax. |
20 | | //! |
21 | | //! - `formatting` (_implicitly enables `std`_) |
22 | | //! |
23 | | //! Enables formatting of most structs. |
24 | | //! |
25 | | //! - `parsing` |
26 | | //! |
27 | | //! Enables parsing of most structs. |
28 | | //! |
29 | | //! - `local-offset` (_implicitly enables `std`_) |
30 | | //! |
31 | | //! This feature enables a number of methods that allow obtaining the system's UTC offset. |
32 | | //! |
33 | | //! - `large-dates` |
34 | | //! |
35 | | //! By default, only years within the ±9999 range (inclusive) are supported. If you need support |
36 | | //! for years outside this range, consider enabling this feature; the supported range will be |
37 | | //! increased to ±999,999. |
38 | | //! |
39 | | //! Note that enabling this feature has some costs, as it means forgoing some optimizations. |
40 | | //! Ambiguities may be introduced when parsing that would not otherwise exist. |
41 | | //! |
42 | | //! - `serde` |
43 | | //! |
44 | | //! Enables [serde](https://docs.rs/serde) support for all types. |
45 | | //! |
46 | | //! - `serde-human-readable` (_implicitly enables `serde`, `formatting`, and `parsing`_) |
47 | | //! |
48 | | //! Allows serde representations to use a human-readable format. This is determined by the |
49 | | //! serializer, not the user. If this feature is not enabled or if the serializer requests a |
50 | | //! non-human-readable format, a format optimized for binary representation will be used. |
51 | | //! |
52 | | //! Libraries should never enable this feature, as the decision of what format to use should be up |
53 | | //! to the user. |
54 | | //! |
55 | | //! - `rand` |
56 | | //! |
57 | | //! Enables [rand](https://docs.rs/rand) support for all types. |
58 | | //! |
59 | | //! - `quickcheck` (_implicitly enables `alloc`_) |
60 | | //! |
61 | | //! Enables [quickcheck](https://docs.rs/quickcheck) support for all types. |
62 | | //! |
63 | | //! - `wasm-bindgen` |
64 | | //! |
65 | | //! Enables [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen) support for converting |
66 | | //! [JavaScript dates](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Date.html), as |
67 | | //! well as obtaining the UTC offset from JavaScript. |
68 | | |
69 | | #![doc(html_playground_url = "https://play.rust-lang.org")] |
70 | | #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_notable_trait))] |
71 | | #![no_std] |
72 | | #![doc(html_favicon_url = "https://avatars0.githubusercontent.com/u/55999857")] |
73 | | #![doc(html_logo_url = "https://avatars0.githubusercontent.com/u/55999857")] |
74 | | #![doc(test(attr(deny(warnings))))] |
75 | | |
76 | | #[allow(unused_extern_crates)] |
77 | | #[cfg(feature = "alloc")] |
78 | | extern crate alloc; |
79 | | |
80 | | #[cfg(feature = "std")] |
81 | | extern crate std; |
82 | | |
83 | | mod date; |
84 | | mod duration; |
85 | | pub mod error; |
86 | | pub mod ext; |
87 | | #[cfg(any(feature = "formatting", feature = "parsing"))] |
88 | | pub mod format_description; |
89 | | #[cfg(feature = "formatting")] |
90 | | pub mod formatting; |
91 | | mod hint; |
92 | | #[cfg(feature = "std")] |
93 | | mod instant; |
94 | | mod internal_macros; |
95 | | mod interop; |
96 | | #[cfg(feature = "macros")] |
97 | | pub mod macros; |
98 | | mod month; |
99 | | mod offset_date_time; |
100 | | #[cfg(feature = "parsing")] |
101 | | pub mod parsing; |
102 | | mod primitive_date_time; |
103 | | #[cfg(feature = "quickcheck")] |
104 | | mod quickcheck; |
105 | | #[cfg(feature = "rand")] |
106 | | mod rand; |
107 | | #[cfg(feature = "serde")] |
108 | | pub mod serde; |
109 | | mod sys; |
110 | | #[cfg(test)] |
111 | | mod tests; |
112 | | mod time; |
113 | | mod utc_date_time; |
114 | | mod utc_offset; |
115 | | pub mod util; |
116 | | mod weekday; |
117 | | |
118 | | pub use time_core::convert; |
119 | | |
120 | | pub use crate::date::Date; |
121 | | pub use crate::duration::Duration; |
122 | | pub use crate::error::Error; |
123 | | #[doc(hidden)] |
124 | | #[cfg(feature = "std")] |
125 | | #[allow(deprecated)] |
126 | | pub use crate::instant::Instant; |
127 | | pub use crate::month::Month; |
128 | | pub use crate::offset_date_time::OffsetDateTime; |
129 | | pub use crate::primitive_date_time::PrimitiveDateTime; |
130 | | pub use crate::time::Time; |
131 | | pub use crate::utc_date_time::UtcDateTime; |
132 | | pub use crate::utc_offset::UtcOffset; |
133 | | pub use crate::weekday::Weekday; |
134 | | |
135 | | /// An alias for [`std::result::Result`] with a generic error from the time crate. |
136 | | pub type Result<T> = core::result::Result<T, Error>; |
137 | | |
138 | | /// This is a separate function to reduce the code size of `expect_opt!`. |
139 | | #[inline(never)] |
140 | | #[cold] |
141 | | #[track_caller] |
142 | 0 | const fn expect_failed(message: &str) -> ! { |
143 | 0 | panic!("{}", message) |
144 | | } |
145 | | |
146 | | /// Returns the size of the pointed-to value in bytes. |
147 | | /// |
148 | | /// This is a `const fn` in the standard library starting in Rust 1.85. When MSRV is at least that, |
149 | | /// this can be removed. |
150 | | #[allow(unused_qualifications)] // added to prelude after MSRV |
151 | 0 | const fn size_of_val<T>(_: &T) -> usize { |
152 | 0 | core::mem::size_of::<T>() |
153 | 0 | } Unexecuted instantiation: time::size_of_val::<i32> Unexecuted instantiation: time::size_of_val::<i128> Unexecuted instantiation: time::size_of_val::<i64> |