Substitute get(0) with first() (#10847)

Substitute calls to `get(0)` with `first()`, improving readability.
This commit is contained in:
Federico Rinaldi 2023-12-02 23:13:42 +01:00 committed by GitHub
parent 24c6a7df05
commit 0400ef059b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View file

@ -644,7 +644,7 @@ fn get_visibility_flag_value(meta_list: &MetaList) -> Result<ShaderStageVisibili
} }
if flags.len() == 1 { if flags.len() == 1 {
if let Some(flag) = flags.get(0) { if let Some(flag) = flags.first() {
if flag == VISIBILITY_ALL { if flag == VISIBILITY_ALL {
return Ok(ShaderStageVisibility::All); return Ok(ShaderStageVisibility::All);
} else if flag == VISIBILITY_NONE { } else if flag == VISIBILITY_NONE {

View file

@ -266,7 +266,7 @@ pub fn prepare_windows(
// For future HDR output support, we'll need to request a format that supports HDR, // 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. // 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. // 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 { for available_format in formats {
// Rgba8UnormSrgb and Bgra8UnormSrgb and the only sRGB formats wgpu exposes that we can use for surfaces. // Rgba8UnormSrgb and Bgra8UnormSrgb and the only sRGB formats wgpu exposes that we can use for surfaces.
if available_format == TextureFormat::Rgba8UnormSrgb if available_format == TextureFormat::Rgba8UnormSrgb

View file

@ -561,7 +561,7 @@ fn init_materials(
let mut materials = Vec::with_capacity(capacity); let mut materials = Vec::with_capacity(capacity);
materials.push(assets.add(ColorMaterial { materials.push(assets.add(ColorMaterial {
color: Color::WHITE, color: Color::WHITE,
texture: textures.get(0).cloned(), texture: textures.first().cloned(),
})); }));
let mut color_rng = StdRng::seed_from_u64(42); let mut color_rng = StdRng::seed_from_u64(42);

View file

@ -221,7 +221,7 @@ fn init_materials(
let mut materials = Vec::with_capacity(capacity); let mut materials = Vec::with_capacity(capacity);
materials.push(assets.add(StandardMaterial { materials.push(assets.add(StandardMaterial {
base_color: Color::WHITE, base_color: Color::WHITE,
base_color_texture: textures.get(0).cloned(), base_color_texture: textures.first().cloned(),
..default() ..default()
})); }));