mirror of
https://github.com/RGBCube/Site
synced 2025-07-31 13:07:46 +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::{
|
||||
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))
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue