Skip to content

Commit c043c97

Browse files
committed
feat(http/body-eos): EosRef<'a, E>: Clone + Copy
this commit introduces clone and copy implementations for the `EosRef<'a, E>` type used to inspect and classify the outcome of a request or response body. as the documentation comment notes in the commit below, this enum only contains immutable references to other values: a header map or an error. other variants are empty tags. ```rust pub enum EosRef<'a, E = Error> { None, Trailers(&'a HeaderMap), Error(&'a E), Cancelled, } ``` this commit makes this type implicitly clonable. Signed-off-by: katelyn martin <[email protected]>
1 parent 7b3f752 commit c043c97

File tree

1 file changed

+18
-0
lines changed
  • linkerd/http/body-eos/src

1 file changed

+18
-0
lines changed

linkerd/http/body-eos/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,21 @@ where
130130
};
131131
}
132132
}
133+
134+
// === impl EosRef ===
135+
136+
/// A reference to the end of a stream can be cheaply cloned.
137+
///
138+
/// Each of the variants are empty tags, or immutable references.
139+
impl<'a, E> Clone for EosRef<'a, E> {
140+
fn clone(&self) -> Self {
141+
match self {
142+
Self::None => Self::None,
143+
Self::Cancelled => Self::Cancelled,
144+
Self::Trailers(trls) => Self::Trailers(trls),
145+
Self::Error(err) => Self::Error(err),
146+
}
147+
}
148+
}
149+
150+
impl<'a, E> Copy for EosRef<'a, E> {}

0 commit comments

Comments
 (0)