Skip to content

Commit

Permalink
Use backticks for documentation examples
Browse files Browse the repository at this point in the history
The rustdoc documentation and the book only show examples as escaped
with backticks.
  • Loading branch information
robyoung authored and botahamec committed May 26, 2022
1 parent 0d7886e commit 416e69c
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 412 deletions.
16 changes: 8 additions & 8 deletions src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ impl<Tz: TimeZone> DateTime<Tz> {
///
/// # Example
///
/// ~~~~
/// ```
/// use chrono::{DateTime, TimeZone, NaiveDateTime, Utc};
///
/// let dt = DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(61, 0), Utc);
/// assert_eq!(Utc.timestamp(61, 0), dt);
/// ~~~~
/// ```
//
// note: this constructor is purposely not named to `new` to discourage the direct usage.
#[inline]
Expand Down Expand Up @@ -158,7 +158,7 @@ impl<Tz: TimeZone> DateTime<Tz> {
///
/// # Example
///
/// ~~~~
/// ```
/// use chrono::Utc;
/// use chrono::TimeZone;
///
Expand All @@ -167,7 +167,7 @@ impl<Tz: TimeZone> DateTime<Tz> {
///
/// let dt = Utc.ymd(2001, 9, 9).and_hms_milli(1, 46, 40, 555);
/// assert_eq!(dt.timestamp_millis(), 1_000_000_000_555);
/// ~~~~
/// ```
#[inline]
pub fn timestamp_millis(&self) -> i64 {
self.datetime.timestamp_millis()
Expand All @@ -182,7 +182,7 @@ impl<Tz: TimeZone> DateTime<Tz> {
///
/// # Example
///
/// ~~~~
/// ```
/// use chrono::Utc;
/// use chrono::TimeZone;
///
Expand All @@ -191,7 +191,7 @@ impl<Tz: TimeZone> DateTime<Tz> {
///
/// let dt = Utc.ymd(2001, 9, 9).and_hms_micro(1, 46, 40, 555);
/// assert_eq!(dt.timestamp_micros(), 1_000_000_000_000_555);
/// ~~~~
/// ```
#[inline]
pub fn timestamp_micros(&self) -> i64 {
self.datetime.timestamp_micros()
Expand All @@ -206,7 +206,7 @@ impl<Tz: TimeZone> DateTime<Tz> {
///
/// # Example
///
/// ~~~~
/// ```
/// use chrono::Utc;
/// use chrono::TimeZone;
///
Expand All @@ -215,7 +215,7 @@ impl<Tz: TimeZone> DateTime<Tz> {
///
/// let dt = Utc.ymd(2001, 9, 9).and_hms_nano(1, 46, 40, 555);
/// assert_eq!(dt.timestamp_nanos(), 1_000_000_000_000_000_555);
/// ~~~~
/// ```
#[inline]
pub fn timestamp_nanos(&self) -> i64 {
self.datetime.timestamp_nanos()
Expand Down
24 changes: 12 additions & 12 deletions src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,26 +835,26 @@ impl<'a, I: Iterator<Item = B> + Clone, B: Borrow<Item<'a>>> fmt::Display for De
///
/// # Example
///
/// ~~~~
/// ```
/// use chrono::Weekday;
///
/// assert_eq!("Sunday".parse::<Weekday>(), Ok(Weekday::Sun));
/// assert!("any day".parse::<Weekday>().is_err());
/// ~~~~
/// ```
///
/// The parsing is case-insensitive.
///
/// ~~~~
/// ```
/// # use chrono::Weekday;
/// assert_eq!("mON".parse::<Weekday>(), Ok(Weekday::Mon));
/// ~~~~
/// ```
///
/// Only the shortest form (e.g. `sun`) and the longest form (e.g. `sunday`) is accepted.
///
/// ~~~~
/// ```
/// # use chrono::Weekday;
/// assert!("thurs".parse::<Weekday>().is_err());
/// ~~~~
/// ```
impl FromStr for Weekday {
type Err = ParseWeekdayError;

Expand Down Expand Up @@ -908,27 +908,27 @@ where
///
/// # Example
///
/// ~~~~
/// ```
/// use chrono::Month;
///
/// assert_eq!("January".parse::<Month>(), Ok(Month::January));
/// assert!("any day".parse::<Month>().is_err());
/// ~~~~
/// ```
///
/// The parsing is case-insensitive.
///
/// ~~~~
/// ```
/// # use chrono::Month;
/// assert_eq!("fEbruARy".parse::<Month>(), Ok(Month::February));
/// ~~~~
/// ```
///
/// Only the shortest form (e.g. `jan`) and the longest form (e.g. `january`) is accepted.
///
/// ~~~~
/// ```
/// # use chrono::Month;
/// assert!("septem".parse::<Month>().is_err());
/// assert!("Augustin".parse::<Month>().is_err());
/// ~~~~
/// ```
impl FromStr for Month {
type Err = ParseMonthError;

Expand Down

0 comments on commit 416e69c

Please sign in to comment.