summaryrefslogtreecommitdiffstats
path: root/vendor/chrono/src/offset/mod.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/chrono/src/offset/mod.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/chrono/src/offset/mod.rs')
-rw-r--r--vendor/chrono/src/offset/mod.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/vendor/chrono/src/offset/mod.rs b/vendor/chrono/src/offset/mod.rs
index 09d0714e9..ee1fe7e23 100644
--- a/vendor/chrono/src/offset/mod.rs
+++ b/vendor/chrono/src/offset/mod.rs
@@ -52,6 +52,7 @@ pub enum LocalResult<T> {
impl<T> LocalResult<T> {
/// Returns `Some` only when the conversion result is unique, or `None` otherwise.
+ #[must_use]
pub fn single(self) -> Option<T> {
match self {
LocalResult::Single(t) => Some(t),
@@ -60,6 +61,7 @@ impl<T> LocalResult<T> {
}
/// Returns `Some` for the earliest possible conversion result, or `None` if none.
+ #[must_use]
pub fn earliest(self) -> Option<T> {
match self {
LocalResult::Single(t) | LocalResult::Ambiguous(t, _) => Some(t),
@@ -68,6 +70,7 @@ impl<T> LocalResult<T> {
}
/// Returns `Some` for the latest possible conversion result, or `None` if none.
+ #[must_use]
pub fn latest(self) -> Option<T> {
match self {
LocalResult::Single(t) | LocalResult::Ambiguous(_, t) => Some(t),
@@ -76,6 +79,7 @@ impl<T> LocalResult<T> {
}
/// Maps a `LocalResult<T>` into `LocalResult<U>` with given function.
+ #[must_use]
pub fn map<U, F: FnMut(T) -> U>(self, mut f: F) -> LocalResult<U> {
match self {
LocalResult::None => LocalResult::None,
@@ -92,6 +96,7 @@ impl<Tz: TimeZone> LocalResult<Date<Tz>> {
///
/// Propagates any error. Ambiguous result would be discarded.
#[inline]
+ #[must_use]
pub fn and_time(self, time: NaiveTime) -> LocalResult<DateTime<Tz>> {
match self {
LocalResult::Single(d) => {
@@ -106,6 +111,7 @@ impl<Tz: TimeZone> LocalResult<Date<Tz>> {
///
/// Propagates any error. Ambiguous result would be discarded.
#[inline]
+ #[must_use]
pub fn and_hms_opt(self, hour: u32, min: u32, sec: u32) -> LocalResult<DateTime<Tz>> {
match self {
LocalResult::Single(d) => {
@@ -121,6 +127,7 @@ impl<Tz: TimeZone> LocalResult<Date<Tz>> {
///
/// Propagates any error. Ambiguous result would be discarded.
#[inline]
+ #[must_use]
pub fn and_hms_milli_opt(
self,
hour: u32,
@@ -142,6 +149,7 @@ impl<Tz: TimeZone> LocalResult<Date<Tz>> {
///
/// Propagates any error. Ambiguous result would be discarded.
#[inline]
+ #[must_use]
pub fn and_hms_micro_opt(
self,
hour: u32,
@@ -163,6 +171,7 @@ impl<Tz: TimeZone> LocalResult<Date<Tz>> {
///
/// Propagates any error. Ambiguous result would be discarded.
#[inline]
+ #[must_use]
pub fn and_hms_nano_opt(
self,
hour: u32,
@@ -181,6 +190,8 @@ impl<Tz: TimeZone> LocalResult<Date<Tz>> {
impl<T: fmt::Debug> LocalResult<T> {
/// Returns the single unique conversion result, or panics accordingly.
+ #[must_use]
+ #[track_caller]
pub fn unwrap(self) -> T {
match self {
LocalResult::None => panic!("No such local time"),