Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more cross-links throughout documentation #290

Merged
merged 2 commits into from
Oct 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,10 @@ 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
/// be set to midnight.
/// Create a [`PrimitiveDateTime`] using the existing date. The [`Time`]
/// component will be set to midnight.
///
/// ```rust
/// # use time_macros::{date, datetime};
Expand All @@ -607,7 +607,8 @@ 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};
Expand All @@ -620,8 +621,8 @@ impl Date {
PrimitiveDateTime::new(self, time)
}

/// 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;
Expand All @@ -643,7 +644,8 @@ 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;
Expand All @@ -666,8 +668,8 @@ 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;
Expand All @@ -690,7 +692,8 @@ 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;
Expand Down
70 changes: 35 additions & 35 deletions src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*`.
///
Expand All @@ -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};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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::*`.
///
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -442,16 +442,16 @@ 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
/// [`NumericalStdDuration`] for clarity.
/// 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`.
/// See [this RFC](https://github.com/rust-lang/rfcs/pull/2632) for details.
///
/// # Examples
///
/// Basic construction of `std::time::Duration`s.
/// Basic construction of [`std::time::Duration`]s.
///
/// ```rust
/// # use time::ext::NumericalStdDurationShort;
Expand All @@ -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
Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/format/date.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Formatting helpers for a `Date`.
//! Formatting helpers for a [`Date`].

#![allow(non_snake_case)]

Expand Down
22 changes: 11 additions & 11 deletions src/format/deferred_format.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! The `DeferredFormat` struct, acting as an intermediary between a request to
//! format and the final output.
//! The [`DeferredFormat`] struct, acting as an intermediary between a request
//! to format and the final output.

use crate::{
format::{format_specifier, parse_fmt_string, well_known, Format, FormatItem},
Expand All @@ -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<Date>,
/// The `Time` to use for formatting.
/// The [`Time`] to use for formatting.
time: Option<Time>,
/// The `UtcOffset` to use for formatting.
/// The [`UtcOffset`] to use for formatting.
offset: Option<UtcOffset>,
/// The list of items used to display the item.
format: Format<'a>,
Expand All @@ -31,35 +31,35 @@ impl<'a> DeferredFormat<'a> {
}
}

/// Provide the `Date` component.
/// Provide the [`Date`] component.
pub(crate) fn with_date(&mut self, date: Date) -> &mut Self {
self.date = Some(date);
self
}

/// Provide the `Time` component.
/// Provide the [`Time`] component.
pub(crate) fn with_time(&mut self, time: Time) -> &mut Self {
self.time = Some(time);
self
}

/// Provide the `UtcOffset` component.
/// Provide the [`UtcOffset`] component.
pub(crate) fn with_offset(&mut self, offset: UtcOffset) -> &mut Self {
self.offset = Some(offset);
self
}

/// Obtain the `Date` component.
/// Obtain the [`Date`] component.
pub(crate) const fn date(&self) -> Option<Date> {
self.date
}

/// Obtain the `Time` component.
/// Obtain the [`Time`] component.
pub(crate) const fn time(&self) -> Option<Time> {
self.time
}

/// Obtain the `UtcOffset` component.
/// Obtain the [`UtcOffset`] component.
pub(crate) const fn offset(&self) -> Option<UtcOffset> {
self.offset
}
Expand Down
2 changes: 1 addition & 1 deletion src/format/format.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! The `Format` struct and its implementations.
//! The [`Format`] struct and its implementations.

/// Various well-known formats, along with the possibility for a custom format
/// (provided either at compile-time or runtime).
Expand Down
2 changes: 1 addition & 1 deletion src/format/offset.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Formatting helpers for a `UtcOffset`.
//! Formatting helpers for a [`UtcOffset`].

#![allow(non_snake_case)]

Expand Down
2 changes: 1 addition & 1 deletion src/format/time.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Formatting helpers for a `Time`.
//! Formatting helpers for a [`Time`].

#![allow(non_snake_case)]

Expand Down
17 changes: 9 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,30 +231,30 @@ macro_rules! const_try_opt {
};
}

/// The `Date` struct and its associated `impl`s.
/// The [`Date`] struct and its associated `impl`s.
mod date;
/// The `Duration` struct and its associated `impl`s.
/// The [`Duration`] struct and its associated `impl`s.
mod duration;
/// Various error types returned by methods in the time crate.
pub mod error;
/// Extension traits.
pub mod ext;
mod format;
/// The `Instant` struct and its associated `impl`s.
/// The [`Instant`] struct and its associated `impl`s.
#[cfg(feature = "std")]
mod instant;
/// The `OffsetDateTime` struct and its associated `impl`s.
/// The [`OffsetDateTime`] struct and its associated `impl`s.
mod offset_date_time;
/// The `PrimitiveDateTime` struct and its associated `impl`s.
/// The [`PrimitiveDateTime`] struct and its associated `impl`s.
mod primitive_date_time;
#[cfg(feature = "rand")]
mod rand;
#[cfg(feature = "serde")]
#[allow(missing_copy_implementations, missing_debug_implementations)]
pub mod serde;
/// The `Time` struct and its associated `impl`s.
/// The [`Time`] struct and its associated `impl`s.
mod time_mod;
/// The `UtcOffset` struct and its associated `impl`s.
/// The [`UtcOffset`] struct and its associated `impl`s.
mod utc_offset;
pub mod util;
/// Days of the week.
Expand Down Expand Up @@ -369,7 +369,8 @@ pub use time_mod::Time;
pub use utc_offset::UtcOffset;
pub use weekday::Weekday;

/// An alias for `Result` with a generic error from the time crate.
/// An alias for [`std::result::Result`] with a generic error from the time
/// crate.
pub type Result<T> = core::result::Result<T, Error>;

/// A collection of imports that are widely useful.
Expand Down
Loading