1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-08-01 13:37:49 +00:00

Remove useless allocations using Cow

This commit is contained in:
RGBCube 2024-01-06 15:29:56 +03:00
parent 979e4c32f6
commit 7a62b78af2
No known key found for this signature in database
3 changed files with 11 additions and 5 deletions

View file

@ -1,3 +1,5 @@
use std::borrow::Cow;
use maud::{
html,
Markup,
@ -13,7 +15,8 @@ pub fn extension_of(path: &str) -> Option<&str> {
pub enum Js {
Shared(&'static str),
Owned(String),
#[allow(dead_code)]
Owned(Cow<'static, str>),
}
impl Render for Js {
@ -36,18 +39,20 @@ impl Render for Js {
}
pub mod js {
#[allow(unused_macros)]
macro_rules! owned {
($path:literal) => {
crate::asset::Js::Owned(::embed::string!($path).to_string())
crate::asset::Js::Owned(::embed::string!($path))
};
}
#[allow(unused_imports)]
pub(crate) use owned;
}
pub enum Css {
Shared(&'static str),
Owned(String),
Owned(Cow<'static, str>),
}
impl Render for Css {
@ -72,7 +77,7 @@ impl Render for Css {
pub mod css {
macro_rules! owned {
($path:literal) => {
crate::asset::Css::Owned(::embed::string!($path).to_string())
crate::asset::Css::Owned(::embed::string!($path))
};
}

View file

@ -22,6 +22,7 @@ pub static MANIFEST: LazyLock<Manifest> = LazyLock::new(|| {
});
/// Enum used to incidate which page we are on.
#[allow(dead_code)]
pub enum Page {
Home,
About,

View file

@ -22,7 +22,7 @@ pub fn create(title: Option<&str>, page: Page, body: Markup) -> Markup {
.{page} {{
font-style: italic;
}}
", page = page.as_str())))
", page = page.as_str()).into()))
},
html! {
.not-flex {