From f0e036dd54494072248e6006fa69a59f8420a573 Mon Sep 17 00:00:00 2001 From: Nil Gradisnik Date: Sat, 2 Dec 2017 22:38:08 -0800 Subject: [PATCH] Clippy cleanup --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- src/main.rs | 6 +++--- src/markdown.rs | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5853701..72c34e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,17 +98,17 @@ dependencies = [ [[package]] name = "clippy" -version = "0.0.174" +version = "0.0.175" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy_lints 0.0.174 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy_lints 0.0.175 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "clippy_lints" -version = "0.0.174" +version = "0.0.175" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -385,7 +385,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "markdown-rs" version = "0.1.0" dependencies = [ - "clippy 0.0.174 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy 0.0.175 (registry+https://github.com/rust-lang/crates.io-index)", "comrak 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "gio 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "gtk 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -719,8 +719,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum cairo-sys-rs 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c6e18fecaeac51809db57f45f4553cc0975225a7eb435a7a7e91e5e8113a84d" "checksum cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "be1057b8462184f634c3a208ee35b0f935cfd94b694b26deadccd98732088d7b" "checksum clap 2.28.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dc34bf7d5d66268b466b9852bca925ec1d2650654dab4da081e63fd230145c2e" -"checksum clippy 0.0.174 (registry+https://github.com/rust-lang/crates.io-index)" = "1b03ded6eba74b16dbeb598be58e874bc72f6cf12f7ccc577b328091e1d4392a" -"checksum clippy_lints 0.0.174 (registry+https://github.com/rust-lang/crates.io-index)" = "9b8e508648d6d41040e0061f45fc5562b3af5c8a7d67853f15841fb531c8e984" +"checksum clippy 0.0.175 (registry+https://github.com/rust-lang/crates.io-index)" = "2dae056aaec8acd5fc26722234cc9fa03b969a860d9aef0da6c5e5c996ce66ae" +"checksum clippy_lints 0.0.175 (registry+https://github.com/rust-lang/crates.io-index)" = "d04f24bc10870e19880865d8f206168993bfc6df9cc7335c0692cad98378a4b6" "checksum comrak 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7bd4bf98681629d26adefa0e7d9d6d6d242ab2495c38e811d726d40a594de324" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" diff --git a/Cargo.toml b/Cargo.toml index 3d99d4e..70cee8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,4 +18,4 @@ default-features = false features = ["v3_22"] [dev-dependencies] -clippy = "0.0.174" +clippy = "0.0.175" diff --git a/src/main.rs b/src/main.rs index 1ff84fa..84150d6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,7 +78,7 @@ fn build_ui(application: >k::Application) { let _ = reader.read_to_string(&mut contents); text_view.get_buffer().unwrap().set_text(&contents); - markdown_view.get_buffer().unwrap().set_text(&string_to_html(contents)); + markdown_view.get_buffer().unwrap().set_text(&string_to_html(&contents)); } file_chooser.destroy(); @@ -87,14 +87,14 @@ fn build_ui(application: >k::Application) { text_view.connect_key_release_event(clone!(text_view, markdown_view, live_button => move |_, _| { if live_button.get_active() { let buffer = text_view.get_buffer().unwrap(); - markdown_view.get_buffer().unwrap().set_text(&buffer_to_html(buffer)); + markdown_view.get_buffer().unwrap().set_text(&buffer_to_html(&buffer)); } Inhibit(true) })); render_button.connect_clicked(clone!(text_view, markdown_view => move |_| { let buffer = text_view.get_buffer().unwrap(); - markdown_view.get_buffer().unwrap().set_text(&buffer_to_html(buffer)); + markdown_view.get_buffer().unwrap().set_text(&buffer_to_html(&buffer)); })); about_button.connect_clicked(clone!(about_dialog => move |_| { diff --git a/src/markdown.rs b/src/markdown.rs index 2b18874..80d6144 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -5,7 +5,7 @@ use gtk::TextBuffer; use comrak::{markdown_to_html, ComrakOptions}; -pub fn string_to_html(text: String) -> String { +pub fn string_to_html(text: &str) -> String { let options = ComrakOptions { hardbreaks: true, ext_table: true, @@ -13,12 +13,12 @@ pub fn string_to_html(text: String) -> String { ..ComrakOptions::default() }; - markdown_to_html(&text, &options) + markdown_to_html(text, &options) } -pub fn buffer_to_html(buffer: TextBuffer) -> String { +pub fn buffer_to_html(buffer: &TextBuffer) -> String { let (start, end) = buffer.get_bounds(); let text = buffer.get_text(&start, &end, false); - string_to_html(text.unwrap()) + string_to_html(&text.unwrap()) } -- 2.39.2