diff --git a/design/src/server/anatomy.md b/design/src/server/anatomy.md index f025e14e146..6a4cec026cc 100644 --- a/design/src/server/anatomy.md +++ b/design/src/server/anatomy.md @@ -840,4 +840,17 @@ pub struct Parts { } ``` -This is commonly used to access types stored within [`Extensions`](https://docs.rs/http/0.2.8/http/struct.Extensions.html) which have been inserted by a middleware. +This is commonly used to access types stored within [`Extensions`](https://docs.rs/http/0.2.8/http/struct.Extensions.html) which have been inserted by a middleware. Here is the `FromParts` implementation supporting this: + +```rust +impl FromParts for Extension +where + T: Clone + Send + Sync + 'static, +{ + type Rejection = MissingExtension; + + fn from_parts(parts: &mut http::request::Parts) -> Result { + parts.extensions.remove::().map(Extension).ok_or(MissingExtension) + } +} +```