From d335b0e59bf1ff84913249a40932f03fa70327fd Mon Sep 17 00:00:00 2001 From: Olivier Pinon Date: Tue, 3 Nov 2020 13:40:19 +0100 Subject: [PATCH] Fix clippy --- crates/bevy_text/src/draw.rs | 2 +- crates/bevy_text/src/glyph_brush.rs | 12 ++++++++---- crates/bevy_text/src/pipeline.rs | 4 ++-- examples/ui/text_debug.rs | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/crates/bevy_text/src/draw.rs b/crates/bevy_text/src/draw.rs index 9cdadb8d1db179..a87cecea9b9219 100644 --- a/crates/bevy_text/src/draw.rs +++ b/crates/bevy_text/src/draw.rs @@ -91,7 +91,7 @@ impl<'a> Drawable for DrawableText<'a> { // set global bindings context.set_bind_groups_from_bindings(draw, &mut [self.render_resource_bindings])?; - for tv in self.text_vertices.borrow() { + for tv in &**self.text_vertices { let atlas_render_resource_bindings = self .asset_render_resource_bindings .get_mut(&tv.atlas_info.texture_atlas) diff --git a/crates/bevy_text/src/glyph_brush.rs b/crates/bevy_text/src/glyph_brush.rs index db54979545b22f..1ec1d35f3a620e 100644 --- a/crates/bevy_text/src/glyph_brush.rs +++ b/crates/bevy_text/src/glyph_brush.rs @@ -106,11 +106,11 @@ impl GlyphBrush { let bounds = outlined_glyph.px_bounds(); let handle_font_atlas: Handle = handle.as_weak(); let font_atlas_set = font_atlas_set_storage - .get_or_insert_with(handle_font_atlas, || FontAtlasSet::default()); + .get_or_insert_with(handle_font_atlas, FontAtlasSet::default); let atlas_info = font_atlas_set .get_glyph_atlas_info(font_size, glyph_id) - .map(|gaf| Ok(gaf)) + .map(Ok) .unwrap_or_else(|| { font_atlas_set.add_glyph_to_atlas( texture_atlases, @@ -163,11 +163,15 @@ pub struct TextVertex { #[derive(Debug, Default, Clone)] pub struct TextVertices(Vec); -impl TextVertices { - pub fn borrow(&self) -> &Vec { +impl std::ops::Deref for TextVertices { + type Target = Vec; + + fn deref(&self) -> &Self::Target { &self.0 } +} +impl TextVertices { pub fn set(&mut self, vertices: Vec) { self.0 = vertices; } diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index b8b92ceb1bd520..1d5ca3ca26f60a 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -76,10 +76,10 @@ impl TextPipeline { pub fn get_or_insert_font_id(&mut self, handle: Handle, font: &Font) -> FontId { let brush = &mut self.brush; - self.map_font_id + *self + .map_font_id .entry(handle.id) .or_insert_with(|| brush.add_font(handle.clone(), font.font.clone())) - .clone() } pub fn queue_text( diff --git a/examples/ui/text_debug.rs b/examples/ui/text_debug.rs index 87bec88b2b8c21..8ae5c311c26c6d 100644 --- a/examples/ui/text_debug.rs +++ b/examples/ui/text_debug.rs @@ -116,7 +116,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res) { text: Text { value: "This\ntext has\nline breaks and also a set width in the bottom left" .to_string(), - font: font.clone(), + font, style: TextStyle { font_size: 50.0, color: Color::WHITE,