Skip to content

Commit

Permalink
ServiceLayerExt
Browse files Browse the repository at this point in the history
  • Loading branch information
lz1998 committed Sep 8, 2023
1 parent 18fdd56 commit 3915044
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions motore/src/layer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod ext;
mod identity;
mod layer_fn;
mod layers;
mod service_layer;
mod stack;
#[cfg(feature = "tower")]
mod tower_adapter;
Expand All @@ -22,6 +23,7 @@ pub use self::{
identity::Identity,
layer_fn::{layer_fn, LayerFn},
layers::Layers,
service_layer::ServiceLayerExt,
stack::Stack,
};

Expand Down
16 changes: 16 additions & 0 deletions motore/src/layer/service_layer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use super::Layer;

pub trait ServiceLayerExt: Sized {
fn layer<L>(self, l: L) -> L::Service
where
L: Layer<Self>;
}

impl<S> ServiceLayerExt for S {
fn layer<L>(self, l: L) -> L::Service
where
L: Layer<Self>,
{
Layer::layer(l, self)
}
}

0 comments on commit 3915044

Please sign in to comment.