Skip to content

Commit

Permalink
feat(http): add Default trait to Body
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nickgonzales committed May 1, 2017
1 parent df1095d commit f61708b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/http/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ impl Default for Body {
}
}

impl Default for Body {
fn default() -> Body {
Body::empty()
}
}

impl Stream for Body {
type Item = Chunk;
type Error = ::Error;
Expand Down Expand Up @@ -107,6 +113,12 @@ impl From<&'static str> for Body {
}
}

impl From<Option<Body>> for Body {
fn from (body: Option<Body>) -> Body {
body.unwrap_or_default()
}
}

fn _assert_send_sync() {
fn _assert_send<T: Send>() {}
fn _assert_sync<T: Sync>() {}
Expand Down

0 comments on commit f61708b

Please sign in to comment.