From def0891fab0fd668dbf2f933c677237a3c56bb0d Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Thu, 23 Feb 2023 15:52:24 -0500 Subject: [PATCH] [O] Implement resp for Vec also --- backend/src/macros.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/macros.rs b/backend/src/macros.rs index 9311965..a1ef477 100644 --- a/backend/src/macros.rs +++ b/backend/src/macros.rs @@ -1,11 +1,14 @@ +use std::collections::HashMap; use std::path::PathBuf; -use hyper::{Body, header, http, Response, StatusCode}; +use duplicate::duplicate_item; +use hyper::{Body, header, http, Request, Response, StatusCode}; -pub trait StringExt { +pub trait Resp { fn resp(&self, status: u16) -> http::Result>; } -impl StringExt for String { +#[duplicate_item(name; [String]; [Vec])] +impl Resp for name { fn resp(&self, status: u16) -> http::Result> { Response::builder().header(header::ACCESS_CONTROL_ALLOW_ORIGIN, "*") .status(StatusCode::from_u16(status).unwrap()).body(Body::from(self.to_owned()))