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:
parent
979e4c32f6
commit
7a62b78af2
3 changed files with 11 additions and 5 deletions
13
src/asset.rs
13
src/asset.rs
|
@ -1,3 +1,5 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use maud::{
|
use maud::{
|
||||||
html,
|
html,
|
||||||
Markup,
|
Markup,
|
||||||
|
@ -13,7 +15,8 @@ pub fn extension_of(path: &str) -> Option<&str> {
|
||||||
|
|
||||||
pub enum Js {
|
pub enum Js {
|
||||||
Shared(&'static str),
|
Shared(&'static str),
|
||||||
Owned(String),
|
#[allow(dead_code)]
|
||||||
|
Owned(Cow<'static, str>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for Js {
|
impl Render for Js {
|
||||||
|
@ -36,18 +39,20 @@ impl Render for Js {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod js {
|
pub mod js {
|
||||||
|
#[allow(unused_macros)]
|
||||||
macro_rules! owned {
|
macro_rules! owned {
|
||||||
($path:literal) => {
|
($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(crate) use owned;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Css {
|
pub enum Css {
|
||||||
Shared(&'static str),
|
Shared(&'static str),
|
||||||
Owned(String),
|
Owned(Cow<'static, str>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Render for Css {
|
impl Render for Css {
|
||||||
|
@ -72,7 +77,7 @@ impl Render for Css {
|
||||||
pub mod css {
|
pub mod css {
|
||||||
macro_rules! owned {
|
macro_rules! owned {
|
||||||
($path:literal) => {
|
($path:literal) => {
|
||||||
crate::asset::Css::Owned(::embed::string!($path).to_string())
|
crate::asset::Css::Owned(::embed::string!($path))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ pub static MANIFEST: LazyLock<Manifest> = LazyLock::new(|| {
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Enum used to incidate which page we are on.
|
/// Enum used to incidate which page we are on.
|
||||||
|
#[allow(dead_code)]
|
||||||
pub enum Page {
|
pub enum Page {
|
||||||
Home,
|
Home,
|
||||||
About,
|
About,
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub fn create(title: Option<&str>, page: Page, body: Markup) -> Markup {
|
||||||
.{page} {{
|
.{page} {{
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}}
|
}}
|
||||||
", page = page.as_str())))
|
", page = page.as_str()).into()))
|
||||||
},
|
},
|
||||||
html! {
|
html! {
|
||||||
.not-flex {
|
.not-flex {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue