Skip to content

Commit e7425e6

Browse files
committed
Remove pin-project dependency
The only thing it was generating is written out into the source instead.
1 parent 880c6c7 commit e7425e6

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

tower/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ retry = ["__common", "tokio/time"]
6464
spawn-ready = ["__common", "futures-util", "tokio/sync", "tokio/rt", "util", "tracing"]
6565
steer = []
6666
timeout = ["pin-project-lite", "tokio/time"]
67-
util = ["__common", "futures-util", "pin-project"]
67+
util = ["__common", "futures-util"]
6868

6969
[dependencies]
7070
tower-layer = { version = "0.3.1", path = "../tower-layer" }
@@ -80,7 +80,6 @@ tokio = { version = "1", optional = true, features = ["sync"] }
8080
tokio-stream = { version = "0.1.0", optional = true }
8181
tokio-util = { version = "0.6.3", default-features = false, optional = true }
8282
tracing = { version = "0.1.2", optional = true }
83-
pin-project = { version = "1", optional = true }
8483
pin-project-lite = { version = "0.2.7", optional = true }
8584

8685
[dev-dependencies]

tower/src/util/either.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! See [`Either`] documentation for more details.
44
55
use futures_core::ready;
6-
use pin_project::pin_project;
76
use std::{
87
future::Future,
98
pin::Pin,
@@ -17,13 +16,28 @@ use tower_service::Service;
1716
/// Both services must be of the same request, response, and error types.
1817
/// [`Either`] is useful for handling conditional branching in service middleware
1918
/// to different inner service types.
20-
#[pin_project(project = EitherProj)]
2119
#[derive(Clone, Debug)]
2220
pub enum Either<A, B> {
2321
/// One type of backing [`Service`].
24-
A(#[pin] A),
22+
A(A),
2523
/// The other type of backing [`Service`].
26-
B(#[pin] B),
24+
B(B),
25+
}
26+
27+
impl<A, B> Either<A, B> {
28+
fn project(self: Pin<&mut Self>) -> EitherProj<'_, A, B> {
29+
unsafe {
30+
match self.get_unchecked_mut() {
31+
Self::A(a) => EitherProj::A(Pin::new_unchecked(a)),
32+
Self::B(b) => EitherProj::B(Pin::new_unchecked(b)),
33+
}
34+
}
35+
}
36+
}
37+
38+
enum EitherProj<'p, A: 'p, B: 'p> {
39+
A(Pin<&'p mut A>),
40+
B(Pin<&'p mut B>),
2741
}
2842

2943
impl<A, B, Request> Service<Request> for Either<A, B>

0 commit comments

Comments
 (0)