summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget/canvas/path.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-02-03 17:18:05 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-02-03 17:18:05 +0700
commitf56c8a7361ceb215bce68e88bd6ce402e2694693 (patch)
treeec4d7ef8a63cf9ce0a77c28c9beeeaa7f3d64efc /graphics/src/widget/canvas/path.rs
parent76c03de58729783513504f8115d7381f9a52fd23 (diff)
downloadiced-f56c8a7361ceb215bce68e88bd6ce402e2694693.tar.gz
iced-f56c8a7361ceb215bce68e88bd6ce402e2694693.tar.bz2
iced-f56c8a7361ceb215bce68e88bd6ce402e2694693.zip
Ask for a slice of segments instead of ownership in `LineDash`
Diffstat (limited to 'graphics/src/widget/canvas/path.rs')
-rw-r--r--graphics/src/widget/canvas/path.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/graphics/src/widget/canvas/path.rs b/graphics/src/widget/canvas/path.rs
index bc258b67..cb7e5035 100644
--- a/graphics/src/widget/canvas/path.rs
+++ b/graphics/src/widget/canvas/path.rs
@@ -71,15 +71,11 @@ impl Path {
}
}
-pub(super) fn dashed(path: &Path, line_dash: LineDash) -> Path {
+pub(super) fn dashed(path: &Path, line_dash: LineDash<'_>) -> Path {
Path::new(|builder| {
- let segments_odd = line_dash.segments.len() % 2 == 1;
-
- let segments = segments_odd
- .then(|| {
- [&line_dash.segments[..], &line_dash.segments[..]].concat()
- })
- .unwrap_or(line_dash.segments);
+ let segments_odd = (line_dash.segments.len() % 2 == 1).then(|| {
+ [&line_dash.segments[..], &line_dash.segments[..]].concat()
+ });
let mut draw_line = false;
@@ -106,7 +102,10 @@ pub(super) fn dashed(path: &Path, line_dash: LineDash) -> Path {
true
},
index: line_dash.offset,
- intervals: &segments,
+ intervals: segments_odd
+ .as_ref()
+ .map(Vec::as_slice)
+ .unwrap_or(line_dash.segments),
},
);
})