From c1f724e8bc9f61bc5a90c70c0df31e0601488d16 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 26 Apr 2023 12:07:46 +0200 Subject: [PATCH] if possible, use into instead of to_owned --- src/config.rs | 8 ++++---- src/misc/github.rs | 2 +- src/misc/markdown.rs | 6 +++--- src/routes/agreements.rs | 2 +- src/routes/blog.rs | 12 ++++++------ src/routes/contrib.rs | 6 +++--- src/routes/index.rs | 4 ++-- src/routes/networks.rs | 4 ++-- src/routes/portfolio.rs | 4 ++-- src/routes/web3.rs | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4b45c82..7dc9756 100644 --- a/src/config.rs +++ b/src/config.rs @@ -27,9 +27,9 @@ impl FileConfig { /// Initialize with default values fn new() -> Self { Self { - scheme: Some("http".to_owned()), + scheme: Some("http".into()), port: Some(8080), - app_name: Some("EWP".to_owned()), + app_name: Some("EWP".into()), ..FileConfig::default() } } @@ -93,7 +93,7 @@ pub fn get_config(file_path: &str) -> Config { let static_dir = "static".to_owned(); let templates_dir = "templates".to_owned(); let files_root = init( - "dist".to_owned(), + "dist".into(), static_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 { // The static folder is minimized only in release mode if cfg!(debug_assertions) { - ".".to_owned() + ".".into() } else { let cfg = minify_html::Cfg { keep_closing_tags: true, diff --git a/src/misc/github.rs b/src/misc/github.rs index 5fff66c..eae1ac6 100644 --- a/src/misc/github.rs +++ b/src/misc/github.rs @@ -67,7 +67,7 @@ pub async fn fetch_pr() -> Result, Error> { let mut list = vec![]; resp.items.iter().for_each(|p| { 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(), status: if p.pull_request.merged_at.is_none() { if p.state == "closed" { diff --git a/src/misc/markdown.rs b/src/misc/markdown.rs index 0b33e73..20d7a50 100644 --- a/src/misc/markdown.rs +++ b/src/misc/markdown.rs @@ -43,11 +43,11 @@ pub fn get_options() -> ComrakOptions { header_ids: Some(String::new()), footnotes: true, description_lists: true, - front_matter_delimiter: Some("---".to_owned()), + front_matter_delimiter: Some("---".into()), }, parse: ComrakParseOptions { smart: true, // could be boring - default_info_string: Some("plaintext".to_owned()), + default_info_string: Some("plaintext".into()), relaxed_tasklist_matching: true, }, render: ComrakRenderOptions { @@ -86,7 +86,7 @@ pub fn read(raw_text: &str) -> File { metadata: Metadata { info: metadata, 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), }, content: html_content, diff --git a/src/routes/agreements.rs b/src/routes/agreements.rs index 13cd744..e677c0d 100644 --- a/src/routes/agreements.rs +++ b/src/routes/agreements.rs @@ -51,7 +51,7 @@ pub async fn robots() -> impl Responder { #[once(time = 60)] fn build_robotstxt() -> String { // TODO, see https://www.robotstxt.org/orig.html - "User-agent: * Allow: /".to_owned() + "User-agent: * Allow: /".into() } #[get("/sitemap.xml")] diff --git a/src/routes/blog.rs b/src/routes/blog.rs index 1d5279e..80b3c2b 100644 --- a/src/routes/blog.rs +++ b/src/routes/blog.rs @@ -39,8 +39,8 @@ pub fn build_index(config: Config) -> String { posts, }, Infos { - page_title: Some("Blog".to_owned()), - page_desc: Some("Liste des posts d'Anri".to_owned()), + page_title: Some("Blog".into()), + page_desc: Some("Liste des posts d'Anri".into()), page_kw: Some(["blog", "blogging"].join(", ")), }, ) @@ -80,19 +80,19 @@ fn get_posts(location: &str) -> Vec { metadata.title = match metadata.title { Some(title) => Some(title), - None => Some(file_without_ext.to_owned()), + None => Some(file_without_ext.into()), }; metadata } Err(_) => FileMetadata { - title: Some(file_without_ext.to_owned()), + title: Some(file_without_ext.into()), ..FileMetadata::default() }, }; Post { - url: file_without_ext.to_owned(), + url: file_without_ext.into(), title: file_metadata.title.unwrap(), date: file_metadata.date.unwrap_or({ let m = f.metadata().unwrap(); @@ -148,7 +148,7 @@ fn get_post(post: &mut Option, filename: String) -> Infos { Infos { 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(", ")), } } diff --git a/src/routes/contrib.rs b/src/routes/contrib.rs index 5200c42..e0d24ba 100644 --- a/src/routes/contrib.rs +++ b/src/routes/contrib.rs @@ -62,7 +62,7 @@ pub async fn build_page(config: Config) -> String { map.entry(project_name).and_modify(|v| v.push(project)); } else { data.push(Project { - name: project_name.to_owned(), + name: project_name.into(), url: p.project_url.to_owned(), pulls_merged: Vec::new(), pulls_closed: Vec::new(), @@ -140,8 +140,8 @@ pub async fn build_page(config: Config) -> String { "contrib.html", data, Infos { - page_title: Some("Mes contributions".to_owned()), - page_desc: Some("Contributions à l'opensource par Anri".to_owned()), + page_title: Some("Mes contributions".into()), + page_desc: Some("Contributions à l'opensource par Anri".into()), page_kw: None, }, ) diff --git a/src/routes/index.rs b/src/routes/index.rs index a37308c..7a5f5ae 100644 --- a/src/routes/index.rs +++ b/src/routes/index.rs @@ -14,8 +14,8 @@ pub fn build_page(config: Config) -> String { "index.html", (), Infos { - page_title: Some("Mylloon".to_owned()), - page_desc: Some("Page principale".to_owned()), + page_title: Some("Mylloon".into()), + page_desc: Some("Page principale".into()), page_kw: None, }, ) diff --git a/src/routes/networks.rs b/src/routes/networks.rs index db8c308..66f6a02 100644 --- a/src/routes/networks.rs +++ b/src/routes/networks.rs @@ -14,8 +14,8 @@ pub fn build_page(config: Config) -> String { "networks.html", (), Infos { - page_title: Some("Mes réseaux".to_owned()), - page_desc: Some("Réseaux d'Anri".to_owned()), + page_title: Some("Mes réseaux".into()), + page_desc: Some("Réseaux d'Anri".into()), page_kw: None, }, ) diff --git a/src/routes/portfolio.rs b/src/routes/portfolio.rs index ddcd15d..0e08597 100644 --- a/src/routes/portfolio.rs +++ b/src/routes/portfolio.rs @@ -75,8 +75,8 @@ pub fn build_page(config: Config) -> String { err_msg: "is empty", }, Infos { - page_title: Some("Portfolio".to_owned()), - page_desc: Some("Portfolio d'Anri".to_owned()), + page_title: Some("Portfolio".into()), + page_desc: Some("Portfolio d'Anri".into()), page_kw: None, }, ) diff --git a/src/routes/web3.rs b/src/routes/web3.rs index 82d341e..7b632f9 100644 --- a/src/routes/web3.rs +++ b/src/routes/web3.rs @@ -14,8 +14,8 @@ pub fn build_page(config: Config) -> String { "web3.html", (), Infos { - page_title: Some("Mylloon".to_owned()), - page_desc: Some("Coin reculé de l'internet".to_owned()), + page_title: Some("Mylloon".into()), + page_desc: Some("Coin reculé de l'internet".into()), page_kw: None, }, )