From 06b173189a96e1f3732442ad5b71bc3cf6476482 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Sat, 31 Oct 2020 02:42:48 +0100 Subject: [PATCH 1/2] Add more cross-links throughout documentation --- src/date.rs | 14 ++++---- src/ext.rs | 68 +++++++++++++++++------------------ src/format/date.rs | 2 +- src/format/deferred_format.rs | 20 +++++------ src/format/format.rs | 2 +- src/format/offset.rs | 2 +- src/format/time.rs | 2 +- src/lib.rs | 17 ++++----- src/offset_date_time.rs | 22 ++++++------ src/primitive_date_time.rs | 10 +++--- src/rand.rs | 2 +- src/time_mod.rs | 20 +++++------ src/utc_offset.rs | 2 +- 13 files changed, 92 insertions(+), 91 deletions(-) diff --git a/src/date.rs b/src/date.rs index d92c12ef9..f9d6c93ef 100644 --- a/src/date.rs +++ b/src/date.rs @@ -594,9 +594,9 @@ impl Date { } } -/// Methods to add a `Time` component, resulting in a `PrimitiveDateTime`. +/// Methods to add a [`Time`] component, resulting in a [`PrimitiveDateTime`]. impl Date { - /// Create a `PrimitiveDateTime` using the existing date. The `Time` component will + /// Create a [`PrimitiveDateTime`] using the existing date. The [`Time`] component will /// be set to midnight. /// /// ```rust @@ -607,7 +607,7 @@ impl Date { PrimitiveDateTime::new(self, Time::midnight()) } - /// Create a `PrimitiveDateTime` using the existing date and the provided `Time`. + /// Create a [`PrimitiveDateTime`] using the existing date and the provided [`Time`]. /// /// ```rust /// # use time_macros::{date, datetime, time}; @@ -620,7 +620,7 @@ impl Date { PrimitiveDateTime::new(self, time) } - /// Attempt to create a `PrimitiveDateTime` using the existing date and the + /// Attempt to create a [`PrimitiveDateTime`] using the existing date and the /// provided time. /// /// ```rust @@ -643,7 +643,7 @@ impl Date { )) } - /// Attempt to create a `PrimitiveDateTime` using the existing date and the provided time. + /// Attempt to create a [`PrimitiveDateTime`] using the existing date and the provided time. /// /// ```rust /// # use time_macros::date; @@ -666,7 +666,7 @@ impl Date { )) } - /// Attempt to create a `PrimitiveDateTime` using the existing date and the + /// Attempt to create a [`PrimitiveDateTime`] using the existing date and the /// provided time. /// /// ```rust @@ -690,7 +690,7 @@ impl Date { )) } - /// Attempt to create a `PrimitiveDateTime` using the existing date and the provided time. + /// Attempt to create a [`PrimitiveDateTime`] using the existing date and the provided time. /// /// ```rust /// # use time_macros::date; diff --git a/src/ext.rs b/src/ext.rs index 6dfeb20a3..b7b36045a 100644 --- a/src/ext.rs +++ b/src/ext.rs @@ -3,7 +3,7 @@ use crate::Duration; use core::time::Duration as StdDuration; -/// Create `Duration`s from primitive and core numeric types. +/// Create [`Duration`]s from primitive and core numeric types. /// /// This trait can be imported with `use time::prelude::*`. /// @@ -12,7 +12,7 @@ use core::time::Duration as StdDuration; /// /// # Examples /// -/// Basic construction of `Duration`s. +/// Basic construction of [`Duration`]s. /// /// ```rust /// # use time::{Duration, ext::NumericalDuration}; @@ -40,7 +40,7 @@ use core::time::Duration as StdDuration; /// assert_eq!((-5).weeks(), Duration::weeks(-5)); /// ``` /// -/// Just like any other `Duration`, they can be added, subtracted, etc. +/// Just like any other [`Duration`], they can be added, subtracted, etc. /// /// ```rust /// # use time::ext::NumericalDuration; @@ -52,21 +52,21 @@ use core::time::Duration as StdDuration; /// value will be truncated. Keep in mind that floating point numbers are /// inherently imprecise and have limited capacity. pub trait NumericalDuration { - /// Create a `Duration` from the number of nanoseconds. + /// Create a [`Duration`] from the number of nanoseconds. fn nanoseconds(self) -> Duration; - /// Create a `Duration` from the number of microseconds. + /// Create a [`Duration`] from the number of microseconds. fn microseconds(self) -> Duration; - /// Create a `Duration` from the number of milliseconds. + /// Create a [`Duration`] from the number of milliseconds. fn milliseconds(self) -> Duration; - /// Create a `Duration` from the number of seconds. + /// Create a [`Duration`] from the number of seconds. fn seconds(self) -> Duration; - /// Create a `Duration` from the number of minutes. + /// Create a [`Duration`] from the number of minutes. fn minutes(self) -> Duration; - /// Create a `Duration` from the number of hours. + /// Create a [`Duration`] from the number of hours. fn hours(self) -> Duration; - /// Create a `Duration` from the number of days. + /// Create a [`Duration`] from the number of days. fn days(self) -> Duration; - /// Create a `Duration` from the number of weeks. + /// Create a [`Duration`] from the number of weeks. fn weeks(self) -> Duration; } @@ -205,7 +205,7 @@ impl_numerical_duration_nonzero![ ]; impl_numerical_duration_float![f32, f64]; -/// Create `std::time::Duration`s from primitive and core numeric types. +/// Create [`std::time::Duration`]s from primitive and core numeric types. /// /// This trait can be imported (alongside others) with `use time::prelude::*`. /// @@ -214,7 +214,7 @@ impl_numerical_duration_float![f32, f64]; /// /// # Examples /// -/// Basic construction of `std::time::Duration`s. +/// Basic construction of [`std::time::Duration`]s. /// /// ```rust /// # use time::ext::NumericalStdDuration; @@ -229,7 +229,7 @@ impl_numerical_duration_float![f32, f64]; /// assert_eq!(5.std_weeks(), Duration::from_secs(5 * 604_800)); /// ``` /// -/// Just like any other `std::time::Duration`, they can be added, subtracted, +/// Just like any other [`std::time::Duration`], they can be added, subtracted, /// etc. /// /// ```rust @@ -248,21 +248,21 @@ impl_numerical_duration_float![f32, f64]; /// value will be truncated. Keep in mind that floating point numbers are /// inherently imprecise and have limited capacity. pub trait NumericalStdDuration { - /// Create a `std::time::Duration` from the number of nanoseconds. + /// Create a [`std::time::Duration`] from the number of nanoseconds. fn std_nanoseconds(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of microseconds. + /// Create a [`std::time::Duration`] from the number of microseconds. fn std_microseconds(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of milliseconds. + /// Create a [`std::time::Duration`] from the number of milliseconds. fn std_milliseconds(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of seconds. + /// Create a [`std::time::Duration`] from the number of seconds. fn std_seconds(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of minutes. + /// Create a [`std::time::Duration`] from the number of minutes. fn std_minutes(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of hours. + /// Create a [`std::time::Duration`] from the number of hours. fn std_hours(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of days. + /// Create a [`std::time::Duration`] from the number of days. fn std_days(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of weeks. + /// Create a [`std::time::Duration`] from the number of weeks. fn std_weeks(self) -> StdDuration; } @@ -442,8 +442,8 @@ impl NumericalStdDuration for f64 { } } -/// Create `std::time::Duration`s from primitive and core numeric types. Unless -/// you are always expecting a `std::time::Duration`, you should prefer to use +/// Create [`std::time::Duration`]s from primitive and core numeric types. Unless +/// you are always expecting a [`std::time::Duration`], you should prefer to use /// [`NumericalStdDuration`] for clarity. /// /// Due to limitations in rustc, these methods are currently _not_ `const fn`. @@ -451,7 +451,7 @@ impl NumericalStdDuration for f64 { /// /// # Examples /// -/// Basic construction of `std::time::Duration`s. +/// Basic construction of [`std::time::Duration`]s. /// /// ```rust /// # use time::ext::NumericalStdDurationShort; @@ -466,7 +466,7 @@ impl NumericalStdDuration for f64 { /// assert_eq!(5.weeks(), Duration::from_secs(5 * 604_800)); /// ``` /// -/// Just like any other `std::time::Duration`, they can be added, subtracted, +/// Just like any other [`std::time::Duration`], they can be added, subtracted, /// etc. /// /// ```rust @@ -479,21 +479,21 @@ impl NumericalStdDuration for f64 { /// value will be truncated. Keep in mind that floating point numbers are /// inherently imprecise and have limited capacity. pub trait NumericalStdDurationShort { - /// Create a `std::time::Duration` from the number of nanoseconds. + /// Create a [`std::time::Duration`] from the number of nanoseconds. fn nanoseconds(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of microseconds. + /// Create a [`std::time::Duration`] from the number of microseconds. fn microseconds(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of milliseconds. + /// Create a [`std::time::Duration`] from the number of milliseconds. fn milliseconds(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of seconds. + /// Create a [`std::time::Duration`] from the number of seconds. fn seconds(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of minutes. + /// Create a [`std::time::Duration`] from the number of minutes. fn minutes(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of hours. + /// Create a [`std::time::Duration`] from the number of hours. fn hours(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of days. + /// Create a [`std::time::Duration`] from the number of days. fn days(self) -> StdDuration; - /// Create a `std::time::Duration` from the number of weeks. + /// Create a [`std::time::Duration`] from the number of weeks. fn weeks(self) -> StdDuration; } diff --git a/src/format/date.rs b/src/format/date.rs index c640af9ad..15ef466ef 100644 --- a/src/format/date.rs +++ b/src/format/date.rs @@ -1,4 +1,4 @@ -//! Formatting helpers for a `Date`. +//! Formatting helpers for a [`Date`]. #![allow(non_snake_case)] diff --git a/src/format/deferred_format.rs b/src/format/deferred_format.rs index b5e7c6afc..b95d5845c 100644 --- a/src/format/deferred_format.rs +++ b/src/format/deferred_format.rs @@ -1,4 +1,4 @@ -//! The `DeferredFormat` struct, acting as an intermediary between a request to +//! The [`DeferredFormat`] struct, acting as an intermediary between a request to //! format and the final output. use crate::{ @@ -10,11 +10,11 @@ use core::fmt::{self, Display, Formatter}; /// A struct containing all the necessary information to display the inner type. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub(crate) struct DeferredFormat<'a> { - /// The `Date` to use for formatting. + /// The [`Date`] to use for formatting. date: Option, - /// The `Time` to use for formatting. + /// The [`Time`] to use for formatting. time: Option