Ask for a slice of segments instead of ownership in LineDash

This commit is contained in:
Héctor Ramón Jiménez 2022-02-03 17:18:05 +07:00
parent 76c03de587
commit f56c8a7361
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
5 changed files with 26 additions and 26 deletions

View file

@ -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),
},
);
})