Skip to content

Commit

Permalink
Clipy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ManevilleF committed Jan 28, 2022
1 parent ae6f921 commit ceb555a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
32 changes: 18 additions & 14 deletions crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,27 +203,31 @@ pub fn extract_atlas_uinodes(
if !visibility.is_visible || uinode.size == Vec2::ZERO {
continue;
}
let atlas = texture_atlases.get(ui_atlas.atlas.clone_weak()).expect(
format!(
"Failed to retrieve `TextureAtlas` from handle {:?}",
ui_atlas.atlas
)
.as_str(),
);
let atlas = texture_atlases
.get(ui_atlas.atlas.clone_weak())
.unwrap_or_else(|| {
panic!(
"Failed to retrieve `TextureAtlas` from handle {:?}",
ui_atlas.atlas
)
});
// Skip loading images
if !images.contains(atlas.texture.clone_weak()) {
continue;
}
let image = atlas.texture.clone_weak();
let atlas_size = Some(atlas.size);
let color = color.map_or(Color::default(), |c| c.0);
let rect = atlas.textures.get(ui_atlas.index).copied().expect(
format!(
"TextureAtlas {:?} as no texture at index {}",
ui_atlas.atlas, ui_atlas.index
)
.as_str(),
);
let rect = atlas
.textures
.get(ui_atlas.index)
.copied()
.unwrap_or_else(|| {
panic!(
"TextureAtlas {:?} as no texture at index {}",
ui_atlas.atlas, ui_atlas.index
)
});
extracted_uinodes.uinodes.push(ExtractedUiNode {
transform: transform.compute_matrix(),
color,
Expand Down
7 changes: 3 additions & 4 deletions crates/bevy_ui/src/widget/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ pub fn image_sheet_node_system(
) {
for (mut calculated_size, ui_atlas) in query.iter_mut() {
if let Some(atlas) = texture_atlases.get(ui_atlas.atlas.clone_weak()) {
let rect = atlas.textures.get(ui_atlas.index).expect(
format!(
let rect = atlas.textures.get(ui_atlas.index).unwrap_or_else(|| {
panic!(
"TextureAtlas {:?} as no texture at index {}",
ui_atlas.atlas, ui_atlas.index
)
.as_str(),
);
});
let size = Size {
width: rect.width(),
height: rect.height(),
Expand Down

0 comments on commit ceb555a

Please sign in to comment.