Skip to content

Commit

Permalink
fix docstring tests and add must_use attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurtis Nusbaum committed Apr 9, 2023
1 parent 3463010 commit 37569af
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/naive/datetime/mod.rs
Expand Up @@ -902,6 +902,8 @@ impl NaiveDateTime {
/// let tz = FixedOffset::east_opt(5 * hour).unwrap();
/// let dt = NaiveDate::from_ymd_opt(2015, 9, 5).unwrap().and_hms_opt(23, 56, 4).unwrap().and_local_timezone(tz).unwrap();
/// assert_eq!(dt.timezone(), tz);
/// ```
#[must_use]
pub fn and_local_timezone<Tz: TimeZone>(&self, tz: Tz) -> LocalResult<DateTime<Tz>> {
tz.from_local_datetime(self)
}
Expand All @@ -914,6 +916,8 @@ impl NaiveDateTime {
/// use chrono::{NaiveDate, NaiveTime, Utc};
/// let dt = NaiveDate::from_ymd_opt(2023, 1, 30).unwrap().and_hms_opt(19, 32, 33).unwrap().and_utc_timezone();
/// assert_eq!(dt.timezone(), Utc);
/// ```
#[must_use]
pub fn and_utc_timezone(&self) -> DateTime<Utc> {
Utc.from_utc_datetime(self)
}
Expand Down

0 comments on commit 37569af

Please sign in to comment.