Skip to content

Commit

Permalink
Fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisCode committed Nov 3, 2020
1 parent 5374dba commit d335b0e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_text/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions crates/bevy_text/src/glyph_brush.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ impl GlyphBrush {
let bounds = outlined_glyph.px_bounds();
let handle_font_atlas: Handle<FontAtlasSet> = 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,
Expand Down Expand Up @@ -163,11 +163,15 @@ pub struct TextVertex {
#[derive(Debug, Default, Clone)]
pub struct TextVertices(Vec<TextVertex>);

impl TextVertices {
pub fn borrow(&self) -> &Vec<TextVertex> {
impl std::ops::Deref for TextVertices {
type Target = Vec<TextVertex>;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl TextVertices {
pub fn set(&mut self, vertices: Vec<TextVertex>) {
self.0 = vertices;
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_text/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ impl TextPipeline {

pub fn get_or_insert_font_id(&mut self, handle: Handle<Font>, 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(
Expand Down
2 changes: 1 addition & 1 deletion examples/ui/text_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ fn infotext_system(mut commands: Commands, asset_server: Res<AssetServer>) {
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,
Expand Down

0 comments on commit d335b0e

Please sign in to comment.