Skip to content

Commit f61708b

Browse files
committed
feat(http): add Default trait to Body
server::Request has a mandatory Body and client::Request has an optional Body. Having a default for Body makes it easier to merge the two.
1 parent df1095d commit f61708b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/http/body.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ impl Default for Body {
3434
}
3535
}
3636

37+
impl Default for Body {
38+
fn default() -> Body {
39+
Body::empty()
40+
}
41+
}
42+
3743
impl Stream for Body {
3844
type Item = Chunk;
3945
type Error = ::Error;
@@ -107,6 +113,12 @@ impl From<&'static str> for Body {
107113
}
108114
}
109115

116+
impl From<Option<Body>> for Body {
117+
fn from (body: Option<Body>) -> Body {
118+
body.unwrap_or_default()
119+
}
120+
}
121+
110122
fn _assert_send_sync() {
111123
fn _assert_send<T: Send>() {}
112124
fn _assert_sync<T: Sync>() {}

0 commit comments

Comments
 (0)