Skip to content

Commit

Permalink
Change a few method signatures to accept impl Into<String>, instead…
Browse files Browse the repository at this point in the history
… of `&str` (#117)
  • Loading branch information
somedevfox authored Apr 26, 2023
1 parent 6168ea6 commit c285eea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/file_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>, extensions: &[impl ToString]) -> Self {
self.filters.push(Filter {
name: name.into(),
extensions: extensions.iter().map(|e| e.to_string()).collect(),
Expand All @@ -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<String>) -> Self {
self.file_name = Some(file_name.into());
self
}
Expand All @@ -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<String>) -> Self {
self.title = Some(title.into());
self
}
Expand Down Expand Up @@ -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<String>, extensions: &[impl ToString]) -> Self {
self.file_dialog = self.file_dialog.add_filter(name, extensions);
self
}
Expand All @@ -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<String>) -> Self {
self.file_dialog = self.file_dialog.set_file_name(file_name);
self
}
Expand All @@ -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<String>) -> Self {
self.file_dialog = self.file_dialog.set_title(title);
self
}
Expand Down
8 changes: 4 additions & 4 deletions src/message_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ 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<String>) -> Self {
self.title = text.into();
self
}

/// 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<String>) -> Self {
self.description = text.into();
self
}
Expand Down Expand Up @@ -101,15 +101,15 @@ 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<String>) -> Self {
self.0 = self.0.set_title(text);
self
}

/// 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<String>) -> Self {
self.0 = self.0.set_description(text);
self
}
Expand Down

0 comments on commit c285eea

Please sign in to comment.