Implement const default function for AssetPath

This commit is contained in:
hodasemi 2023-01-17 07:20:54 +01:00
parent 9e8ef188f8
commit 6557e2ceee

View file

@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};
use std::{fmt::Display, path::Path, str::FromStr};
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub struct AssetPath {
#[serde(skip)]
prefix: Option<String>,
@ -10,6 +10,13 @@ pub struct AssetPath {
}
impl AssetPath {
pub const fn default() -> Self {
Self {
prefix: None,
path: String::new(),
}
}
fn check_prefix(prefix: &str) -> String {
if prefix.ends_with('/') {
prefix.to_string()