Swap unwrap_or_else to unwrap_or_default

This commit is contained in:
Joao Freitas 2023-07-13 14:30:54 +01:00 committed by Héctor Ramón Jiménez
parent 470e13c806
commit 7fe3389cf1
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -58,7 +58,7 @@ where
let text_input = TextInput::new(placeholder, &state.value())
.on_input(TextInputEvent::TextChanged);
let selection = selection.map(T::to_string).unwrap_or_else(String::new);
let selection = selection.map(T::to_string).unwrap_or_default();
Self {
state,
@ -204,7 +204,7 @@ where
/// Creates a new [`State`] for a [`ComboBox`] with the given list of options
/// and selected value.
pub fn with_selection(options: Vec<T>, selection: Option<&T>) -> Self {
let value = selection.map(T::to_string).unwrap_or_else(String::new);
let value = selection.map(T::to_string).unwrap_or_default();
// Pre-build "matcher" strings ahead of time so that search is fast
let option_matchers = build_matchers(&options);