Unverified Commit 71e2a6d9 authored by david-perez's avatar david-perez Committed by GitHub
Browse files

Remove `impl_extension_new_and_deref` macro from `aws-smithy-http-server` (#1290)

This macro is used only once in the codebase.
parent fc6af207
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -82,7 +82,21 @@ impl OperationExtension {
/// These are modeled errors, defined in the Smithy model.
#[derive(Debug, Clone)]
pub struct ModeledErrorExtension(&'static str);
impl_extension_new_and_deref!(ModeledErrorExtension);

impl ModeledErrorExtension {
    /// Creates a new `ModeledErrorExtension`.
    pub fn new(value: &'static str) -> ModeledErrorExtension {
        ModeledErrorExtension(value)
    }
}

impl Deref for ModeledErrorExtension {
    type Target = &'static str;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

/// Extension type used to store the _name_ of the [`crate::runtime_error::RuntimeError`] that
/// occurred during request handling (see [`crate::runtime_error::RuntimeErrorKind::name`]).
+0 −27
Original line number Diff line number Diff line
@@ -84,33 +84,6 @@ macro_rules! opaque_future {

pub use opaque_future;

/// Implements `Deref` for all `Extension` holding a `&'static, str`.
macro_rules! impl_deref {
    ($name:ident) => {
        impl Deref for $name {
            type Target = &'static str;

            fn deref(&self) -> &Self::Target {
                &self.0
            }
        }
    };
}

/// Implements `new` for all `Extension` holding a `&'static, str`.
macro_rules! impl_extension_new_and_deref {
    ($name:ident) => {
        impl $name {
            #[doc = concat!("Returns a new `", stringify!($name), "`.")]
            pub fn new(value: &'static str) -> $name {
                $name(value)
            }
        }

        impl_deref!($name);
    };
}

macro_rules! convert_to_request_rejection {
    ($from:ty, $to:ident) => {
        impl From<$from> for RequestRejection {