Skip to content

Commit

Permalink
Make tower-layer no_std compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
TTWNO committed Jan 25, 2025
1 parent 4d2e4fd commit cc3bf9a
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tower-layer/src/identity.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::Layer;
use std::fmt;
use core::fmt;

/// A no-op middleware.
///
10 changes: 5 additions & 5 deletions tower-layer/src/layer_fn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::Layer;
use std::fmt;
use core::fmt;

/// Returns a new [`LayerFn`] that implements [`Layer`] by calling the
/// given function.
@@ -13,10 +13,10 @@ use std::fmt;
/// # Example
/// ```rust
/// # use tower::Service;
/// # use std::task::{Poll, Context};
/// # use core::task::{Poll, Context};
/// # use tower_layer::{Layer, layer_fn};
/// # use std::fmt;
/// # use std::convert::Infallible;
/// # use core::fmt;
/// # use core::convert::Infallible;
/// #
/// // A middleware that logs requests before forwarding them to another service
/// pub struct LogService<S> {
@@ -88,7 +88,7 @@ where
impl<F> fmt::Debug for LayerFn<F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("LayerFn")
.field("f", &format_args!("{}", std::any::type_name::<F>()))
.field("f", &format_args!("{}", core::any::type_name::<F>()))
.finish()
}
}
6 changes: 4 additions & 2 deletions tower-layer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@
//!
//! [`Service`]: https://docs.rs/tower/*/tower/trait.Service.html
#![no_std]

mod identity;
mod layer_fn;
mod stack;
@@ -41,9 +43,9 @@ pub use self::{
///
/// ```rust
/// # use tower_service::Service;
/// # use std::task::{Poll, Context};
/// # use core::task::{Poll, Context};
/// # use tower_layer::Layer;
/// # use std::fmt;
/// # use core::fmt;
///
/// pub struct LogLayer {
/// target: &'static str,
2 changes: 1 addition & 1 deletion tower-layer/src/stack.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::Layer;
use std::fmt;
use core::fmt;

/// Two middlewares chained together.
#[derive(Clone)]
1 change: 0 additions & 1 deletion tower-service/src/lib.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@ extern crate alloc;
#[cfg(not(feature = "std"))]
use alloc::boxed::Box;


use core::future::Future;
use core::marker::Sized;
use core::result::Result;

0 comments on commit cc3bf9a

Please sign in to comment.