From 9edd0528e49bb77e2217b4f4df6de3311d9f12dd Mon Sep 17 00:00:00 2001 From: Noboru Date: Wed, 29 Mar 2023 22:03:39 +0300 Subject: [PATCH] Change a few method signatures to accept `impl Into`, instead of `&str` --- src/file_dialog.rs | 12 ++++++------ src/message_dialog.rs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/file_dialog.rs b/src/file_dialog.rs index e248442..429bf05 100644 --- a/src/file_dialog.rs +++ b/src/file_dialog.rs @@ -45,7 +45,7 @@ impl FileDialog { /// * Linux /// /// On platforms that don't support filter names, all filters will be merged into one filter - pub fn add_filter(mut self, name: &str, extensions: &[&str]) -> Self { + pub fn add_filter(mut self, name: impl Into, extensions: &[impl ToString]) -> Self { self.filters.push(Filter { name: name.into(), extensions: extensions.iter().map(|e| e.to_string()).collect(), @@ -71,7 +71,7 @@ impl FileDialog { /// * Windows /// * Linux /// * Mac - pub fn set_file_name(mut self, file_name: &str) -> Self { + pub fn set_file_name(mut self, file_name: impl Into) -> Self { self.file_name = Some(file_name.into()); self } @@ -80,7 +80,7 @@ impl FileDialog { /// * Windows /// * Linux /// * Mac (Only below version 10.11) - pub fn set_title(mut self, title: &str) -> Self { + pub fn set_title(mut self, title: impl Into) -> Self { self.title = Some(title.into()); self } @@ -163,7 +163,7 @@ impl AsyncFileDialog { /// * Linux /// /// On platforms that don't support filter names, all filters will be merged into one filter - pub fn add_filter(mut self, name: &str, extensions: &[&str]) -> Self { + pub fn add_filter(mut self, name: impl Into, extensions: &[impl ToString]) -> Self { self.file_dialog = self.file_dialog.add_filter(name, extensions); self } @@ -181,7 +181,7 @@ impl AsyncFileDialog { /// * Windows /// * Linux /// * Mac - pub fn set_file_name(mut self, file_name: &str) -> Self { + pub fn set_file_name(mut self, file_name: impl Into) -> Self { self.file_dialog = self.file_dialog.set_file_name(file_name); self } @@ -190,7 +190,7 @@ impl AsyncFileDialog { /// * Windows /// * Linux /// * Mac (Only below version 10.11) - pub fn set_title(mut self, title: &str) -> Self { + pub fn set_title(mut self, title: impl Into) -> Self { self.file_dialog = self.file_dialog.set_title(title); self } diff --git a/src/message_dialog.rs b/src/message_dialog.rs index 8ef80ae..706c6c8 100644 --- a/src/message_dialog.rs +++ b/src/message_dialog.rs @@ -38,7 +38,7 @@ impl MessageDialog { } /// Set title of a dialog - pub fn set_title(mut self, text: &str) -> Self { + pub fn set_title(mut self, text: impl Into) -> Self { self.title = text.into(); self } @@ -46,7 +46,7 @@ impl MessageDialog { /// Set description of a dialog /// /// Description is a content of a dialog - pub fn set_description(mut self, text: &str) -> Self { + pub fn set_description(mut self, text: impl Into) -> Self { self.description = text.into(); self } @@ -101,7 +101,7 @@ impl AsyncMessageDialog { } /// Set title of a dialog - pub fn set_title(mut self, text: &str) -> Self { + pub fn set_title(mut self, text: impl Into) -> Self { self.0 = self.0.set_title(text); self } @@ -109,7 +109,7 @@ impl AsyncMessageDialog { /// Set description of a dialog /// /// Description is a content of a dialog - pub fn set_description(mut self, text: &str) -> Self { + pub fn set_description(mut self, text: impl Into) -> Self { self.0 = self.0.set_description(text); self }