Skip to content

Commit

Permalink
Substitute get(0) with first() (bevyengine#10847)
Browse files Browse the repository at this point in the history
Substitute calls to `get(0)` with `first()`, improving readability.
Nilirad authored Dec 2, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 24c6a7d commit 0400ef0
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_render/macros/src/as_bind_group.rs
Original file line number Diff line number Diff line change
@@ -644,7 +644,7 @@ fn get_visibility_flag_value(meta_list: &MetaList) -> Result<ShaderStageVisibili
}

if flags.len() == 1 {
if let Some(flag) = flags.get(0) {
if let Some(flag) = flags.first() {
if flag == VISIBILITY_ALL {
return Ok(ShaderStageVisibility::All);
} else if flag == VISIBILITY_NONE {
2 changes: 1 addition & 1 deletion crates/bevy_render/src/view/window/mod.rs
Original file line number Diff line number Diff line change
@@ -266,7 +266,7 @@ pub fn prepare_windows(
// For future HDR output support, we'll need to request a format that supports HDR,
// but as of wgpu 0.15 that is not yet supported.
// Prefer sRGB formats for surfaces, but fall back to first available format if no sRGB formats are available.
let mut format = *formats.get(0).expect("No supported formats for surface");
let mut format = *formats.first().expect("No supported formats for surface");
for available_format in formats {
// Rgba8UnormSrgb and Bgra8UnormSrgb and the only sRGB formats wgpu exposes that we can use for surfaces.
if available_format == TextureFormat::Rgba8UnormSrgb
2 changes: 1 addition & 1 deletion examples/stress_tests/bevymark.rs
Original file line number Diff line number Diff line change
@@ -561,7 +561,7 @@ fn init_materials(
let mut materials = Vec::with_capacity(capacity);
materials.push(assets.add(ColorMaterial {
color: Color::WHITE,
texture: textures.get(0).cloned(),
texture: textures.first().cloned(),
}));

let mut color_rng = StdRng::seed_from_u64(42);
2 changes: 1 addition & 1 deletion examples/stress_tests/many_cubes.rs
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ fn init_materials(
let mut materials = Vec::with_capacity(capacity);
materials.push(assets.add(StandardMaterial {
base_color: Color::WHITE,
base_color_texture: textures.get(0).cloned(),
base_color_texture: textures.first().cloned(),
..default()
}));

0 comments on commit 0400ef0

Please sign in to comment.