Skip to content

Commit 9eee21d

Browse files
authored
Merge pull request #74 from yoshuawuyts/status-trait
Rename ResultExt to Status
2 parents 3f55497 + bf1c598 commit 9eee21d

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "http-types"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
license = "MIT OR Apache-2.0"
55
repository = "https://github.com/http-rs/http-types"
66
documentation = "https://docs.rs/http-types"

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ mod macros;
120120
mod method;
121121
mod request;
122122
mod response;
123-
mod result_ext;
123+
mod status;
124124
mod status_code;
125125
mod type_map;
126126
mod version;
@@ -130,7 +130,7 @@ pub use error::{Error, Result};
130130
pub use method::Method;
131131
pub use request::Request;
132132
pub use response::Response;
133-
pub use result_ext::ResultExt;
133+
pub use status::Status;
134134
pub use status_code::StatusCode;
135135
pub use version::Version;
136136

src/result_ext.rs renamed to src/status.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use crate::{Error, StatusCode};
22
use core::convert::{Infallible, TryInto};
33
use std::error::Error as StdError;
44

5-
/// Provides the `status` method for `Result`.
5+
/// Provides the `status` method for `Result` and `Option`.
66
///
77
/// This trait is sealed and cannot be implemented outside of `http-types`.
8-
pub trait ResultExt<T, E>: private::Sealed {
8+
pub trait Status<T, E>: private::Sealed {
99
/// Wrap the error value with an additional status code.
1010
fn status<S>(self, status: S) -> Result<T, Error>
1111
where
@@ -21,7 +21,7 @@ pub trait ResultExt<T, E>: private::Sealed {
2121
F: FnOnce() -> S;
2222
}
2323

24-
impl<T, E> ResultExt<T, E> for Result<T, E>
24+
impl<T, E> Status<T, E> for Result<T, E>
2525
where
2626
E: StdError + Send + Sync + 'static,
2727
{
@@ -49,7 +49,7 @@ where
4949
}
5050
}
5151

52-
impl<T> ResultExt<T, Infallible> for Option<T> {
52+
impl<T> Status<T, Infallible> for Option<T> {
5353
fn status<S>(self, status: S) -> Result<T, Error>
5454
where
5555
S: TryInto<StatusCode>,

tests/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn ensure_eq() {
4646

4747
#[test]
4848
fn result_ext() {
49-
use http_types::ResultExt;
49+
use http_types::Status;
5050
fn run() -> http_types::Result<()> {
5151
let err = io::Error::new(io::ErrorKind::Other, "Oh no");
5252
Err(err).status(StatusCode::NotFound)?;
@@ -61,7 +61,7 @@ fn result_ext() {
6161

6262
#[test]
6363
fn option_ext() {
64-
use http_types::ResultExt;
64+
use http_types::Status;
6565
fn run() -> http_types::Result<()> {
6666
None.status(StatusCode::NotFound)
6767
}

0 commit comments

Comments
 (0)