summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/src/widget')
-rw-r--r--graphics/src/widget/canvas/path.rs8
-rw-r--r--graphics/src/widget/canvas/path/builder.rs8
-rw-r--r--graphics/src/widget/pure/qr_code.rs8
-rw-r--r--graphics/src/widget/qr_code.rs13
4 files changed, 19 insertions, 18 deletions
diff --git a/graphics/src/widget/canvas/path.rs b/graphics/src/widget/canvas/path.rs
index 1728f060..f834e286 100644
--- a/graphics/src/widget/canvas/path.rs
+++ b/graphics/src/widget/canvas/path.rs
@@ -73,9 +73,8 @@ impl Path {
pub(super) fn dashed(path: &Path, line_dash: LineDash<'_>) -> Path {
Path::new(|builder| {
- let segments_odd = (line_dash.segments.len() % 2 == 1).then(|| {
- [&line_dash.segments[..], &line_dash.segments[..]].concat()
- });
+ let segments_odd = (line_dash.segments.len() % 2 == 1)
+ .then(|| [line_dash.segments, line_dash.segments].concat());
let mut draw_line = false;
@@ -103,8 +102,7 @@ pub(super) fn dashed(path: &Path, line_dash: LineDash<'_>) -> Path {
},
index: line_dash.offset,
intervals: segments_odd
- .as_ref()
- .map(Vec::as_slice)
+ .as_deref()
.unwrap_or(line_dash.segments),
},
);
diff --git a/graphics/src/widget/canvas/path/builder.rs b/graphics/src/widget/canvas/path/builder.rs
index d04dbdde..05316d8a 100644
--- a/graphics/src/widget/canvas/path/builder.rs
+++ b/graphics/src/widget/canvas/path/builder.rs
@@ -53,7 +53,7 @@ impl Builder {
let _ = self.raw.line_to(a);
}
- let _ = self.raw.arc_to(
+ self.raw.arc_to(
math::Vector::new(radius, radius),
math::Angle::radians(0.0),
path::ArcFlags::default(),
@@ -151,3 +151,9 @@ impl Builder {
}
}
}
+
+impl Default for Builder {
+ fn default() -> Self {
+ Self::new()
+ }
+}
diff --git a/graphics/src/widget/pure/qr_code.rs b/graphics/src/widget/pure/qr_code.rs
index 23a8ceb6..bff391fe 100644
--- a/graphics/src/widget/pure/qr_code.rs
+++ b/graphics/src/widget/pure/qr_code.rs
@@ -53,12 +53,12 @@ where
}
}
-impl<'a, Message, B, T> Into<Element<'a, Message, Renderer<B, T>>>
- for QRCode<'a>
+impl<'a, Message, B, T> From<QRCode<'a>>
+ for Element<'a, Message, Renderer<B, T>>
where
B: Backend,
{
- fn into(self) -> Element<'a, Message, Renderer<B, T>> {
- Element::new(self)
+ fn from(qr_code: QRCode<'a>) -> Self {
+ Self::new(qr_code)
}
}
diff --git a/graphics/src/widget/qr_code.rs b/graphics/src/widget/qr_code.rs
index 1eb862ba..1a5c0b0a 100644
--- a/graphics/src/widget/qr_code.rs
+++ b/graphics/src/widget/qr_code.rs
@@ -67,10 +67,7 @@ where
let side_length = (self.state.width + 2 * QUIET_ZONE) as f32
* f32::from(self.cell_size);
- layout::Node::new(Size::new(
- f32::from(side_length),
- f32::from(side_length),
- ))
+ layout::Node::new(Size::new(side_length, side_length))
}
fn draw(
@@ -128,13 +125,13 @@ where
}
}
-impl<'a, Message, B, T> Into<Element<'a, Message, Renderer<B, T>>>
- for QRCode<'a>
+impl<'a, Message, B, T> From<QRCode<'a>>
+ for Element<'a, Message, Renderer<B, T>>
where
B: Backend,
{
- fn into(self) -> Element<'a, Message, Renderer<B, T>> {
- Element::new(self)
+ fn from(qr_code: QRCode<'a>) -> Self {
+ Self::new(qr_code)
}
}