if possible, use into instead of to_owned
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-26 12:07:46 +02:00
parent 39fde5225d
commit c1f724e8bc
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
10 changed files with 26 additions and 26 deletions

View file

@ -27,9 +27,9 @@ impl FileConfig {
/// Initialize with default values /// Initialize with default values
fn new() -> Self { fn new() -> Self {
Self { Self {
scheme: Some("http".to_owned()), scheme: Some("http".into()),
port: Some(8080), port: Some(8080),
app_name: Some("EWP".to_owned()), app_name: Some("EWP".into()),
..FileConfig::default() ..FileConfig::default()
} }
} }
@ -93,7 +93,7 @@ pub fn get_config(file_path: &str) -> Config {
let static_dir = "static".to_owned(); let static_dir = "static".to_owned();
let templates_dir = "templates".to_owned(); let templates_dir = "templates".to_owned();
let files_root = init( let files_root = init(
"dist".to_owned(), "dist".into(),
static_dir.to_owned(), static_dir.to_owned(),
templates_dir.to_owned(), templates_dir.to_owned(),
); );
@ -112,7 +112,7 @@ pub fn get_config(file_path: &str) -> Config {
fn init(dist_dir: String, static_dir: String, templates_dir: String) -> String { fn init(dist_dir: String, static_dir: String, templates_dir: String) -> String {
// The static folder is minimized only in release mode // The static folder is minimized only in release mode
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
".".to_owned() ".".into()
} else { } else {
let cfg = minify_html::Cfg { let cfg = minify_html::Cfg {
keep_closing_tags: true, keep_closing_tags: true,

View file

@ -67,7 +67,7 @@ pub async fn fetch_pr() -> Result<Vec<Project>, Error> {
let mut list = vec![]; let mut list = vec![];
resp.items.iter().for_each(|p| { resp.items.iter().for_each(|p| {
list.push(Project { list.push(Project {
project: p.repository_url.split('/').last().unwrap().to_owned(), project: p.repository_url.split('/').last().unwrap().into(),
project_url: p.repository_url.to_owned(), project_url: p.repository_url.to_owned(),
status: if p.pull_request.merged_at.is_none() { status: if p.pull_request.merged_at.is_none() {
if p.state == "closed" { if p.state == "closed" {

View file

@ -43,11 +43,11 @@ pub fn get_options() -> ComrakOptions {
header_ids: Some(String::new()), header_ids: Some(String::new()),
footnotes: true, footnotes: true,
description_lists: true, description_lists: true,
front_matter_delimiter: Some("---".to_owned()), front_matter_delimiter: Some("---".into()),
}, },
parse: ComrakParseOptions { parse: ComrakParseOptions {
smart: true, // could be boring smart: true, // could be boring
default_info_string: Some("plaintext".to_owned()), default_info_string: Some("plaintext".into()),
relaxed_tasklist_matching: true, relaxed_tasklist_matching: true,
}, },
render: ComrakRenderOptions { render: ComrakRenderOptions {
@ -86,7 +86,7 @@ pub fn read(raw_text: &str) -> File {
metadata: Metadata { metadata: Metadata {
info: metadata, info: metadata,
mermaid: check_mermaid(root, mermaid_name), mermaid: check_mermaid(root, mermaid_name),
syntax_highlight: check_code(root, &[mermaid_name.to_owned()]), syntax_highlight: check_code(root, &[mermaid_name.into()]),
math: check_math(&html_content), math: check_math(&html_content),
}, },
content: html_content, content: html_content,

View file

@ -51,7 +51,7 @@ pub async fn robots() -> impl Responder {
#[once(time = 60)] #[once(time = 60)]
fn build_robotstxt() -> String { fn build_robotstxt() -> String {
// TODO, see https://www.robotstxt.org/orig.html // TODO, see https://www.robotstxt.org/orig.html
"User-agent: * Allow: /".to_owned() "User-agent: * Allow: /".into()
} }
#[get("/sitemap.xml")] #[get("/sitemap.xml")]

View file

@ -39,8 +39,8 @@ pub fn build_index(config: Config) -> String {
posts, posts,
}, },
Infos { Infos {
page_title: Some("Blog".to_owned()), page_title: Some("Blog".into()),
page_desc: Some("Liste des posts d'Anri".to_owned()), page_desc: Some("Liste des posts d'Anri".into()),
page_kw: Some(["blog", "blogging"].join(", ")), page_kw: Some(["blog", "blogging"].join(", ")),
}, },
) )
@ -80,19 +80,19 @@ fn get_posts(location: &str) -> Vec<Post> {
metadata.title = match metadata.title { metadata.title = match metadata.title {
Some(title) => Some(title), Some(title) => Some(title),
None => Some(file_without_ext.to_owned()), None => Some(file_without_ext.into()),
}; };
metadata metadata
} }
Err(_) => FileMetadata { Err(_) => FileMetadata {
title: Some(file_without_ext.to_owned()), title: Some(file_without_ext.into()),
..FileMetadata::default() ..FileMetadata::default()
}, },
}; };
Post { Post {
url: file_without_ext.to_owned(), url: file_without_ext.into(),
title: file_metadata.title.unwrap(), title: file_metadata.title.unwrap(),
date: file_metadata.date.unwrap_or({ date: file_metadata.date.unwrap_or({
let m = f.metadata().unwrap(); let m = f.metadata().unwrap();
@ -148,7 +148,7 @@ fn get_post(post: &mut Option<File>, filename: String) -> Infos {
Infos { Infos {
page_title: Some(format!("Post: {}", title)), page_title: Some(format!("Post: {}", title)),
page_desc: Some("Blog d'Anri".to_owned()), page_desc: Some("Blog d'Anri".into()),
page_kw: Some(["blog", "blogging", "write", "writing"].join(", ")), page_kw: Some(["blog", "blogging", "write", "writing"].join(", ")),
} }
} }

View file

@ -62,7 +62,7 @@ pub async fn build_page(config: Config) -> String {
map.entry(project_name).and_modify(|v| v.push(project)); map.entry(project_name).and_modify(|v| v.push(project));
} else { } else {
data.push(Project { data.push(Project {
name: project_name.to_owned(), name: project_name.into(),
url: p.project_url.to_owned(), url: p.project_url.to_owned(),
pulls_merged: Vec::new(), pulls_merged: Vec::new(),
pulls_closed: Vec::new(), pulls_closed: Vec::new(),
@ -140,8 +140,8 @@ pub async fn build_page(config: Config) -> String {
"contrib.html", "contrib.html",
data, data,
Infos { Infos {
page_title: Some("Mes contributions".to_owned()), page_title: Some("Mes contributions".into()),
page_desc: Some("Contributions à l'opensource par Anri".to_owned()), page_desc: Some("Contributions à l'opensource par Anri".into()),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -14,8 +14,8 @@ pub fn build_page(config: Config) -> String {
"index.html", "index.html",
(), (),
Infos { Infos {
page_title: Some("Mylloon".to_owned()), page_title: Some("Mylloon".into()),
page_desc: Some("Page principale".to_owned()), page_desc: Some("Page principale".into()),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -14,8 +14,8 @@ pub fn build_page(config: Config) -> String {
"networks.html", "networks.html",
(), (),
Infos { Infos {
page_title: Some("Mes réseaux".to_owned()), page_title: Some("Mes réseaux".into()),
page_desc: Some("Réseaux d'Anri".to_owned()), page_desc: Some("Réseaux d'Anri".into()),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -75,8 +75,8 @@ pub fn build_page(config: Config) -> String {
err_msg: "is empty", err_msg: "is empty",
}, },
Infos { Infos {
page_title: Some("Portfolio".to_owned()), page_title: Some("Portfolio".into()),
page_desc: Some("Portfolio d'Anri".to_owned()), page_desc: Some("Portfolio d'Anri".into()),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -14,8 +14,8 @@ pub fn build_page(config: Config) -> String {
"web3.html", "web3.html",
(), (),
Infos { Infos {
page_title: Some("Mylloon".to_owned()), page_title: Some("Mylloon".into()),
page_desc: Some("Coin reculé de l'internet".to_owned()), page_desc: Some("Coin reculé de l'internet".into()),
page_kw: None, page_kw: None,
}, },
) )