Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.

Commit 00a9e01

Browse files
committed
Fix Clippy warnings
1 parent c9e0d1e commit 00a9e01

File tree

5 files changed

+33
-39
lines changed

5 files changed

+33
-39
lines changed

src/backend.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'a, 'b> DrawingBackend for ConrodBackend<'a, 'b> {
9292
style: &S,
9393
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
9494
// Acquire absolute position generator (in parent container)
95-
if let Some(position) = position::PositionParent::from(&self.ui, self.parent) {
95+
if let Some(position) = position::PositionParent::from(self.ui, self.parent) {
9696
// Generate line style
9797
let line_style = conrod::widget::primitive::line::Style::solid()
9898
.color(color::Color::from(&style.color()).into())
@@ -159,7 +159,7 @@ impl<'a, 'b> DrawingBackend for ConrodBackend<'a, 'b> {
159159
style: &S,
160160
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
161161
// Acquire absolute position generator (in parent container)
162-
if let Some(position) = position::PositionParent::from(&self.ui, self.parent) {
162+
if let Some(position) = position::PositionParent::from(self.ui, self.parent) {
163163
// Generate line style
164164
let line_style = conrod::widget::primitive::line::Style::solid()
165165
.color(color::Color::from(&style.color()).into())
@@ -221,7 +221,7 @@ impl<'a, 'b> DrawingBackend for ConrodBackend<'a, 'b> {
221221
style: &S,
222222
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
223223
// Acquire absolute position generator (in parent container)
224-
if let Some(position) = position::PositionParent::from(&self.ui, self.parent) {
224+
if let Some(position) = position::PositionParent::from(self.ui, self.parent) {
225225
// Paint a simplified path, where empty areas are removed and un-necessary points are \
226226
// cleared. This is required for triangulation to work properly, and it reduces \
227227
// the number of triangles on screen to a strict minimum.
@@ -278,17 +278,17 @@ impl<'a, 'b> DrawingBackend for ConrodBackend<'a, 'b> {
278278
let (text_width_estimated, font_size_final) = convert::font_style(text, style.size());
279279

280280
// Generate text style
281-
let mut text_style = conrod::widget::primitive::text::Style::default();
282-
283-
text_style.color = Some(color::Color::from(&style.color()).into());
284-
text_style.font_id = Some(Some(self.font));
285-
text_style.font_size = Some(font_size_final);
286-
287-
text_style.justify = Some(match style.anchor().h_pos {
288-
text_anchor::HPos::Left => conrod::text::Justify::Left,
289-
text_anchor::HPos::Right => conrod::text::Justify::Right,
290-
text_anchor::HPos::Center => conrod::text::Justify::Center,
291-
});
281+
let text_style = conrod::widget::primitive::text::Style {
282+
font_size: Some(font_size_final),
283+
font_id: Some(Some(self.font)),
284+
color: Some(color::Color::from(&style.color()).into()),
285+
justify: Some(match style.anchor().h_pos {
286+
text_anchor::HPos::Left => conrod::text::Justify::Left,
287+
text_anchor::HPos::Right => conrod::text::Justify::Right,
288+
text_anchor::HPos::Center => conrod::text::Justify::Center,
289+
}),
290+
..std::default::Default::default()
291+
};
292292

293293
// Render text widget
294294
conrod::widget::Text::new(text)

src/triangulate/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ pub(crate) struct Polygon {
4141
ll: *mut c_void,
4242
}
4343

44-
pub(crate) struct CDT {
44+
pub(crate) struct Cdt {
4545
ll: *mut c_void,
4646
}
4747

4848
pub(crate) struct TriangleVec {
4949
ll: *mut c_void,
5050

5151
#[allow(dead_code)]
52-
cdt: CDT,
52+
cdt: Cdt,
5353
}
5454

5555
#[derive(Copy, Clone, PartialEq)]
@@ -94,10 +94,10 @@ impl Drop for Polygon {
9494
}
9595
}
9696

97-
impl CDT {
98-
pub(crate) fn new(polygon: Polygon) -> CDT {
97+
impl Cdt {
98+
pub(crate) fn new(polygon: Polygon) -> Cdt {
9999
unsafe {
100-
let rv = CDT {
100+
let rv = Cdt {
101101
ll: p2t_cdt_new(polygon.ll),
102102
};
103103

@@ -118,7 +118,7 @@ impl CDT {
118118
}
119119
}
120120

121-
impl Drop for CDT {
121+
impl Drop for Cdt {
122122
fn drop(&mut self) {
123123
unsafe {
124124
p2t_cdt_free(self.ll);
@@ -164,5 +164,5 @@ pub(crate) fn triangulate_points<'a, I>(points: I) -> TriangleVec
164164
where
165165
I: Iterator<Item = &'a [Scalar; 2]>,
166166
{
167-
CDT::new(Polygon::from_iterator(points)).triangulate()
167+
Cdt::new(Polygon::from_iterator(points)).triangulate()
168168
}

src/utils/color.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ impl From<&BackendColor> for Color {
3030
}
3131
}
3232

33-
impl Into<conrod::color::Color> for Color {
33+
impl From<Color> for conrod::color::Color {
3434
#[inline(always)]
35-
fn into(self) -> conrod::color::Color {
36-
self.0
35+
fn from(c: Color) -> Self {
36+
c.0
3737
}
3838
}
3939

src/utils/path.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ impl<I: Iterator<Item = PathSimplifierPointInner>> Iterator for PathSimplifier<I
3838

3939
fn next(&mut self) -> Option<Self::Item> {
4040
// Branch to source points iterator (exhaust next group)
41-
while let Some(point) = self.source_points.next() {
41+
for point in &mut self.source_points {
4242
// Backtrack in points
43-
if let Some(point_before) = self.last_point {
44-
// Retain current point as 'last point'
45-
self.last_point = Some(point);
4643

44+
// Retain current point as 'last point'
45+
self.last_point = Some(point);
46+
47+
if let Some(point_before) = self.last_point {
4748
// De-duplicate points
4849
if point_before != point {
4950
let mut do_yield = false;
@@ -105,9 +106,6 @@ impl<I: Iterator<Item = PathSimplifierPointInner>> Iterator for PathSimplifier<I
105106
]);
106107
}
107108
}
108-
} else {
109-
// Retain first point as 'last point'
110-
self.last_point = Some(point);
111109
}
112110
}
113111

src/utils/position.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@ pub(crate) struct PositionParent {
1919
impl PositionParent {
2020
#[inline(always)]
2121
pub(crate) fn from(ui: &conrod::UiCell, parent: conrod::widget::Id) -> Option<Self> {
22-
if let Some(parent_rect) = ui.rect_of(parent) {
23-
Some(Self {
24-
x_start: parent_rect.x.start as PositionScalar,
25-
y_end: parent_rect.y.end as PositionScalar,
26-
})
27-
} else {
28-
None
29-
}
22+
ui.rect_of(parent).map(|parent_rect| Self {
23+
x_start: parent_rect.x.start as PositionScalar,
24+
y_end: parent_rect.y.end as PositionScalar,
25+
})
3026
}
3127

3228
#[inline(always)]

0 commit comments

Comments
 (0)