diff options
author | 2021-07-22 20:16:53 +0700 | |
---|---|---|
committer | 2021-07-22 20:22:38 +0700 | |
commit | a866f8742e4ddf5714455519790fed0f961fad66 (patch) | |
tree | 805377d47609364a579597c1c3966250d4f2e03a /graphics | |
parent | 1b3606884747374f1e5599e3c783f36a2f2cac6f (diff) | |
download | iced-a866f8742e4ddf5714455519790fed0f961fad66.tar.gz iced-a866f8742e4ddf5714455519790fed0f961fad66.tar.bz2 iced-a866f8742e4ddf5714455519790fed0f961fad66.zip |
Avoid cloning `placeholder` for `PickList` unnecessarily during `draw`
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/src/widget/pick_list.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/graphics/src/widget/pick_list.rs b/graphics/src/widget/pick_list.rs index 01283bd5..88a590b5 100644 --- a/graphics/src/widget/pick_list.rs +++ b/graphics/src/widget/pick_list.rs @@ -31,7 +31,7 @@ where bounds: Rectangle, cursor_position: Point, selected: Option<String>, - placeholder: Option<String>, + placeholder: Option<&str>, padding: Padding, text_size: u16, font: Font, @@ -70,7 +70,9 @@ where ( Primitive::Group { - primitives: if let Some(label) = selected.or(placeholder) { + primitives: if let Some(label) = + selected.or_else(|| placeholder.map(str::to_string)) + { let label = Primitive::Text { content: label, size: f32::from(text_size), |