Skip to content

Commit bcc630e

Browse files
author
zeroed
committed
Update the documentation adding the "Panics" section
1 parent 98fbcf7 commit bcc630e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/status.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ impl<T, E> Status<T, E> for Result<T, E>
2626
where
2727
E: StdError + Send + Sync + 'static,
2828
{
29+
/// Wrap the error value with an additional status code.
30+
///
31+
/// # Panics
32+
///
33+
/// Panics if [`Status`][status] is not a valid [`StatusCode`][statuscode].
34+
///
35+
/// [status]: crate::Status
36+
/// [statuscode]: crate::StatusCode
2937
fn status<S>(self, status: S) -> Result<T, Error>
3038
where
3139
S: TryInto<StatusCode>,
@@ -39,6 +47,15 @@ where
3947
})
4048
}
4149

50+
/// Wrap the error value with an additional status code that is evaluated
51+
/// lazily only once an error does occur.
52+
///
53+
/// # Panics
54+
///
55+
/// Panics if [`Status`][status] is not a valid [`StatusCode`][statuscode].
56+
///
57+
/// [status]: crate::Status
58+
/// [statuscode]: crate::StatusCode
4259
fn with_status<S, F>(self, f: F) -> Result<T, Error>
4360
where
4461
S: TryInto<StatusCode>,
@@ -55,6 +72,14 @@ where
5572
}
5673

5774
impl<T> Status<T, Infallible> for Option<T> {
75+
/// Wrap the error value with an additional status code.
76+
///
77+
/// # Panics
78+
///
79+
/// Panics if [`Status`][status] is not a valid [`StatusCode`][statuscode].
80+
///
81+
/// [status]: crate::Status
82+
/// [statuscode]: crate::StatusCode
5883
fn status<S>(self, status: S) -> Result<T, Error>
5984
where
6085
S: TryInto<StatusCode>,
@@ -68,6 +93,15 @@ impl<T> Status<T, Infallible> for Option<T> {
6893
})
6994
}
7095

96+
/// Wrap the error value with an additional status code that is evaluated
97+
/// lazily only once an error does occur.
98+
///
99+
/// # Panics
100+
///
101+
/// Panics if [`Status`][status] is not a valid [`StatusCode`][statuscode].
102+
///
103+
/// [status]: crate::Status
104+
/// [statuscode]: crate::StatusCode
71105
fn with_status<S, F>(self, f: F) -> Result<T, Error>
72106
where
73107
S: TryInto<StatusCode>,

0 commit comments

Comments
 (0)