summaryrefslogtreecommitdiffstats
path: root/vendor/time-core
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/time-core
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/time-core')
-rw-r--r--vendor/time-core/.cargo-checksum.json2
-rw-r--r--vendor/time-core/Cargo.toml7
-rw-r--r--vendor/time-core/src/convert.rs156
-rw-r--r--vendor/time-core/src/lib.rs41
4 files changed, 92 insertions, 114 deletions
diff --git a/vendor/time-core/.cargo-checksum.json b/vendor/time-core/.cargo-checksum.json
index 239ee7662..32d6e08d1 100644
--- a/vendor/time-core/.cargo-checksum.json
+++ b/vendor/time-core/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"032c780eaf4ddfde703d5a6b260ad7bad35a5a1ee57a33cacf503f5e47dff6a9","LICENSE-Apache":"b8929fea28678da67251fb2daf9438f67503814211051861612441806d8edb05","LICENSE-MIT":"04620bf27e4a643dd47bf27652320c205acdb776c1f9f24bb8c3bfaba10804c5","src/convert.rs":"59566933f2977d62abbfe39b20be16a85df00db8627211471ccfe182dbbe684c","src/lib.rs":"18020c914b1cd561465e624ef3ea3eef980bd82bc93847e2543bce12da28b043","src/util.rs":"52c1fbf68b71c3582caf0d9a8255378c6c14a737e2df8d7e6d6603b0eb12ca06"},"package":"7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"} \ No newline at end of file
+{"files":{"Cargo.toml":"d90c41d20f37fc3dbc3d88f7715cacafb5aea973030f498e9b2833decdbe63f0","LICENSE-Apache":"b8929fea28678da67251fb2daf9438f67503814211051861612441806d8edb05","LICENSE-MIT":"04620bf27e4a643dd47bf27652320c205acdb776c1f9f24bb8c3bfaba10804c5","src/convert.rs":"354a1b05e8bb1e92eda5dcdecf33dc6cf2ce72b11115ae4cb0909dcd51d2b294","src/lib.rs":"461b752a45b0f819284e8d8e6b2f49d52b3b661026ab84ee64bf04f4daa0a2d2","src/util.rs":"52c1fbf68b71c3582caf0d9a8255378c6c14a737e2df8d7e6d6603b0eb12ca06"},"package":"ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"} \ No newline at end of file
diff --git a/vendor/time-core/Cargo.toml b/vendor/time-core/Cargo.toml
index bbc8a325e..3d6555ebd 100644
--- a/vendor/time-core/Cargo.toml
+++ b/vendor/time-core/Cargo.toml
@@ -11,9 +11,9 @@
[package]
edition = "2021"
-rust-version = "1.65.0"
+rust-version = "1.67.0"
name = "time-core"
-version = "0.1.1"
+version = "0.1.2"
authors = [
"Jacob Pratt <open-source@jhpratt.dev>",
"Time contributors",
@@ -29,4 +29,7 @@ categories = ["date-and-time"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/time-rs/time"
+[package.metadata.docs.rs]
+rustdoc-args = ["--generate-link-to-definition"]
+
[dependencies]
diff --git a/vendor/time-core/src/convert.rs b/vendor/time-core/src/convert.rs
index dae77e9af..9c28f0263 100644
--- a/vendor/time-core/src/convert.rs
+++ b/vendor/time-core/src/convert.rs
@@ -1,88 +1,104 @@
-#![allow(clippy::missing_docs_in_private_items)] // TODO temporary
+//! Conversion between units of time.
-macro_rules! declare_structs {
- ($($t:ident)*) => {$(
- #[derive(Debug, Copy, Clone)]
+use self::sealed::Per;
+
+mod sealed {
+ /// A trait for defining the ratio of two units of time.
+ ///
+ /// This trait is used to implement the `per` method on the various structs.
+ pub trait Per<T> {
+ /// The smallest unsigned integer type that can represent [`VALUE`](Self::VALUE).
+ type Output;
+
+ /// The number of one unit of time in the other.
+ const VALUE: Self::Output;
+ }
+}
+
+/// Declare and implement `Per` for all relevant types. Identity implementations are automatic.
+macro_rules! impl_per {
+ ($($t:ident ($str:literal) per {$(
+ $larger:ident : $output:ty = $value:expr
+ )*})*) => {$(
+ #[doc = concat!("A unit of time representing exactly one ", $str, ".")]
+ #[derive(Debug, Clone, Copy)]
pub struct $t;
impl $t {
- pub const fn per<T>(self, _: T) -> <(Self, T) as Per>::Output
+ #[doc = concat!("Obtain the number of times `", stringify!($t), "` can fit into `T`.")]
+ #[doc = concat!("If `T` is smaller than `", stringify!($t), "`, the code will fail to")]
+ /// compile. The return type is the smallest unsigned integer type that can represent
+ /// the value.
+ ///
+ /// Valid calls:
+ ///
+ #[doc = concat!(" - `", stringify!($t), "::per(", stringify!($t), ")` (returns `u8`)")]
+ $(#[doc = concat!(" - `", stringify!($t), "::per(", stringify!($larger), ")` (returns `", stringify!($output), "`)")])*
+ pub const fn per<T>(_larger: T) -> <Self as Per<T>>::Output
where
- (Self, T): Per,
+ Self: Per<T>,
T: Copy,
{
- <(Self, T)>::VALUE
+ Self::VALUE
}
}
- )*};
-}
-
-declare_structs! {
- Nanosecond
- Microsecond
- Millisecond
- Second
- Minute
- Hour
- Day
- Week
-}
-
-mod sealed {
- pub trait Sealed {}
-}
-pub trait Per: sealed::Sealed {
- type Output;
+ impl Per<$t> for $t {
+ type Output = u8;
- const VALUE: Self::Output;
-}
-
-macro_rules! impl_per {
- ($($t:ty : $x:ident in $y:ident = $val:expr)*) => {$(
- impl sealed::Sealed for ($x, $y) {}
+ const VALUE: u8 = 1;
+ }
- impl Per for ($x, $y) {
- type Output = $t;
+ $(impl Per<$larger> for $t {
+ type Output = $output;
- const VALUE: $t = $val;
- }
+ const VALUE: $output = $value;
+ })*
)*};
}
impl_per! {
- u16: Nanosecond in Microsecond = 1_000
- u32: Nanosecond in Millisecond = 1_000_000
- u32: Nanosecond in Second = 1_000_000_000
- u64: Nanosecond in Minute = 60_000_000_000
- u64: Nanosecond in Hour = 3_600_000_000_000
- u64: Nanosecond in Day = 86_400_000_000_000
- u64: Nanosecond in Week = 604_800_000_000_000
-
- u16: Microsecond in Millisecond = 1_000
- u32: Microsecond in Second = 1_000_000
- u32: Microsecond in Minute = 60_000_000
- u32: Microsecond in Hour = 3_600_000_000
- u64: Microsecond in Day = 86_400_000_000
- u64: Microsecond in Week = 604_800_000_000
-
- u16: Millisecond in Second = 1_000
- u16: Millisecond in Minute = 60_000
- u32: Millisecond in Hour = 3_600_000
- u32: Millisecond in Day = 86_400_000
- u32: Millisecond in Week = 604_800_000
-
- u8: Second in Minute = 60
- u16: Second in Hour = 3_600
- u32: Second in Day = 86_400
- u32: Second in Week = 604_800
-
- u8: Minute in Hour = 60
- u16: Minute in Day = 1_440
- u16: Minute in Week = 10_080
-
- u8: Hour in Day = 24
- u8: Hour in Week = 168
-
- u8: Day in Week = 7
+ Nanosecond ("nanosecond") per {
+ Microsecond: u16 = 1_000
+ Millisecond: u32 = 1_000_000
+ Second: u32 = 1_000_000_000
+ Minute: u64 = 60_000_000_000
+ Hour: u64 = 3_600_000_000_000
+ Day: u64 = 86_400_000_000_000
+ Week: u64 = 604_800_000_000_000
+ }
+ Microsecond ("microsecond") per {
+ Millisecond: u16 = 1_000
+ Second: u32 = 1_000_000
+ Minute: u32 = 60_000_000
+ Hour: u32 = 3_600_000_000
+ Day: u64 = 86_400_000_000
+ Week: u64 = 604_800_000_000
+ }
+ Millisecond ("millisecond") per {
+ Second: u16 = 1_000
+ Minute: u16 = 60_000
+ Hour: u32 = 3_600_000
+ Day: u32 = 86_400_000
+ Week: u32 = 604_800_000
+ }
+ Second ("second") per {
+ Minute: u8 = 60
+ Hour: u16 = 3_600
+ Day: u32 = 86_400
+ Week: u32 = 604_800
+ }
+ Minute ("minute") per {
+ Hour: u8 = 60
+ Day: u16 = 1_440
+ Week: u16 = 10_080
+ }
+ Hour ("hour") per {
+ Day: u8 = 24
+ Week: u8 = 168
+ }
+ Day ("day") per {
+ Week: u8 = 7
+ }
+ Week ("week") per {}
}
diff --git a/vendor/time-core/src/lib.rs b/vendor/time-core/src/lib.rs
index 4f1c53b12..41c354786 100644
--- a/vendor/time-core/src/lib.rs
+++ b/vendor/time-core/src/lib.rs
@@ -3,47 +3,6 @@
//! This crate is an implementation detail of `time` and should not be relied upon directly.
#![no_std]
-#![deny(
- anonymous_parameters,
- clippy::all,
- clippy::alloc_instead_of_core,
- clippy::explicit_auto_deref,
- clippy::obfuscated_if_else,
- clippy::std_instead_of_core,
- clippy::undocumented_unsafe_blocks,
- illegal_floating_point_literal_pattern,
- late_bound_lifetime_arguments,
- path_statements,
- patterns_in_fns_without_body,
- rust_2018_idioms,
- trivial_casts,
- trivial_numeric_casts,
- unreachable_pub,
- unsafe_op_in_unsafe_fn,
- unused_extern_crates,
- rustdoc::broken_intra_doc_links,
- rustdoc::private_intra_doc_links
-)]
-#![warn(
- clippy::dbg_macro,
- clippy::decimal_literal_representation,
- clippy::get_unwrap,
- clippy::missing_docs_in_private_items,
- clippy::nursery,
- clippy::print_stdout,
- clippy::todo,
- clippy::unimplemented,
- clippy::unnested_or_patterns,
- clippy::unwrap_in_result,
- clippy::unwrap_used,
- clippy::use_debug,
- deprecated_in_future,
- missing_copy_implementations,
- missing_debug_implementations,
- unused_qualifications,
- variant_size_differences
-)]
-#![allow(clippy::redundant_pub_crate)]
#![doc(html_favicon_url = "https://avatars0.githubusercontent.com/u/55999857")]
#![doc(html_logo_url = "https://avatars0.githubusercontent.com/u/55999857")]
#![doc(test(attr(deny(warnings))))]