From b9a07197500741a0281a1d1e966b0d9f156eac01 Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Mon, 13 Dec 2021 11:13:09 +0700 Subject: [PATCH 1/2] refactor: migrate panic!() usage to Rust 2021 This commit refactors code to conform to some changes in Rust 2021: - The panic!() macro now uses format_args!() like println!(). - The usage of panic!(x) is now deprecated if x is not a string literal. See: https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html --- src/components/editor/mod.rs | 2 +- src/components/window/file.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/editor/mod.rs b/src/components/editor/mod.rs index dc218b9..b8d3bff 100644 --- a/src/components/editor/mod.rs +++ b/src/components/editor/mod.rs @@ -67,7 +67,7 @@ impl EchidnaCoreEditor { |_, _| {}, |result| { if result.is_err() { - panic!(result.err()); + panic!("Found an error when loading the file into the text editor's buffer. {:#?}", result.err()); } }, ); diff --git a/src/components/window/file.rs b/src/components/window/file.rs index 3a51ce0..1cc5ab9 100644 --- a/src/components/window/file.rs +++ b/src/components/window/file.rs @@ -114,7 +114,7 @@ impl FileImplementedEditor for super::EchidnaWindow { "Couldn't get the page of the current index. Try again." ).downcast::() { Ok(res) => page = res, - Err(e) => panic!(format!("We got an error when trying to downcast the current tab page into EchidnaCoreEditor:\n{}", e)) + Err(e) => panic!("We got an error when trying to downcast the current tab page into EchidnaCoreEditor:\n{}", e) } let buffer: Buffer = page.to_imp().sourceview.buffer().downcast().expect("Could not downcast the editor's buffer to GtkSourceBuffer."); @@ -129,7 +129,7 @@ impl FileImplementedEditor for super::EchidnaWindow { |_, _| {}, |result| { if result.is_err() { - panic!(format!("Found an error while saving the file:\n{}", result.err().expect("No error"))) + panic!("Found an error while saving the file:\n{}", result.err().expect("No error")) } }); From d29223e17f951f6eb339c43dabfe5672f729984c Mon Sep 17 00:00:00 2001 From: Nefo Fortressia Date: Mon, 13 Dec 2021 11:22:33 +0700 Subject: [PATCH 2/2] chore: bump Rust edition to Rust 2021 Follow up of 183d548, which migrate old syntaxes to the new ones. See: https://doc.rust-lang.org/nightly/edition-guide/rust-2021/index.html --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 65a0203..af27a72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "echidna" version = "0.1.0" -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html