diff options
| author | HampusM <hampus@hampusmat.com> | 2026-05-23 19:46:46 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-05-23 19:52:55 +0200 |
| commit | 02afe68342870ce4f37d7e8fb45c985397d6e08d (patch) | |
| tree | a3a83450ea11ed9b6131aac5aca587418f20e708 /engine/src | |
| parent | aa83c5cbc21227a5c647063efcaaca178884da9f (diff) | |
refactor(engine): use Rust edition 2021
This change is because of a rustfmt bug in the 2024 edition.
For example, the following code snippet:
```
struct Value {}
struct ParsingError {}
trait Keyword {}
impl Value {
fn parse<KeywordT: Keyword>(value: &str, line_no: usize) -> Result<Self, ParsingError> {
todo!();
}
}
```
when formatted with `rustfmt --edition 2021 --emit stdout --config max_width=90,brace_style=AlwaysNextLine` becomes:
```
struct Value {}
struct ParsingError {}
trait Keyword {}
impl Value
{
fn parse<KeywordT: Keyword>(value: &str, line_no: usize)
-> Result<Self, ParsingError>
{
todo!();
}
}
```
Diffstat (limited to 'engine/src')
| -rw-r--r-- | engine/src/renderer/main_render_pass.rs | 21 | ||||
| -rw-r--r-- | engine/src/shader.rs | 15 | ||||
| -rw-r--r-- | engine/src/windowing/mouse.rs | 3 |
3 files changed, 21 insertions, 18 deletions
diff --git a/engine/src/renderer/main_render_pass.rs b/engine/src/renderer/main_render_pass.rs index abd1022..04050f8 100644 --- a/engine/src/renderer/main_render_pass.rs +++ b/engine/src/renderer/main_render_pass.rs @@ -1,9 +1,8 @@ +use crate::asset::Assets; +use crate::draw_flags::{DrawFlags, NoDraw, PolygonModeConfig}; use crate::ecs::Query; use crate::ecs::query::term::{With, Without}; use crate::ecs::sole::Single; - -use crate::asset::Assets; -use crate::draw_flags::{DrawFlags, NoDraw, PolygonModeConfig}; use crate::model::{MaterialSearchResult, Model}; use crate::renderer::object::{Id as RendererObjectId, Store as RendererObjectStore}; use crate::renderer::{ @@ -192,9 +191,13 @@ pub fn add_main_render_passes( )); } - if let Some(draw_flags) = draw_flags.as_deref() - && draw_flags.polygon_mode_config != PolygonModeConfig::default() - { + if let Some(draw_flags) = draw_flags.as_deref().and_then(|draw_flags| { + if draw_flags.polygon_mode_config != PolygonModeConfig::default() { + Some(draw_flags) + } else { + None + } + }) { render_pass .commands .push(RendererCommand::UpdateDrawProperties( @@ -223,9 +226,9 @@ pub fn add_main_render_passes( RendererDrawMeshOptions::default(), )); - if let Some(draw_flags) = draw_flags.as_deref() - && draw_flags.polygon_mode_config != PolygonModeConfig::default() - { + if draw_flags.as_deref().is_some_and(|draw_flags| { + draw_flags.polygon_mode_config != PolygonModeConfig::default() + }) { render_pass .commands .push(RendererCommand::UpdateDrawProperties( diff --git a/engine/src/shader.rs b/engine/src/shader.rs index d5611ca..7988724 100644 --- a/engine/src/shader.rs +++ b/engine/src/shader.rs @@ -6,10 +6,6 @@ use std::path::Path; use std::str::Utf8Error; use bitflags::{bitflags, bitflags_match}; -use crate::ecs::pair::{ChildOf, Pair}; -use crate::ecs::phase::{POST_UPDATE as POST_UPDATE_PHASE, Phase, START as START_PHASE}; -use crate::ecs::sole::Single; -use crate::ecs::{Component, Sole, declare_entity}; use shader_slang::{ Blob as SlangBlob, ComponentType as SlangComponentType, @@ -32,6 +28,10 @@ use crate::asset::{ Submitter as AssetSubmitter, }; use crate::builder; +use crate::ecs::pair::{ChildOf, Pair}; +use crate::ecs::phase::{POST_UPDATE as POST_UPDATE_PHASE, Phase, START as START_PHASE}; +use crate::ecs::sole::Single; +use crate::ecs::{Component, Sole, declare_entity}; use crate::shader::default::{ ASSET_LABEL, enqueue_set_shader_bindings as default_shader_enqueue_set_shader_bindings, @@ -77,7 +77,7 @@ pub struct Module impl Module { - pub fn entry_points(&self) -> impl ExactSizeIterator<Item = EntryPoint> + pub fn entry_points(&self) -> impl ExactSizeIterator<Item = EntryPoint> + use<'_> { self.inner .entry_points() @@ -218,8 +218,9 @@ impl<'a> ProgramReflection<'a> }) } - pub fn entry_points(&self) - -> impl ExactSizeIterator<Item = EntryPointReflection<'a>> + pub fn entry_points( + &self, + ) -> impl ExactSizeIterator<Item = EntryPointReflection<'a>> + use<'a> { self.inner .entry_points() diff --git a/engine/src/windowing/mouse.rs b/engine/src/windowing/mouse.rs index 2a3324e..f4969ea 100644 --- a/engine/src/windowing/mouse.rs +++ b/engine/src/windowing/mouse.rs @@ -1,7 +1,6 @@ use std::collections::HashMap; use crate::ecs::Sole; - use crate::vector::Vec2; #[derive(Debug, Default, Clone, Sole)] @@ -48,7 +47,7 @@ impl Buttons /// Returns a iterator that yields buttons and their current states. Only buttons with /// states is included. - pub fn all_current(&self) -> impl Iterator<Item = (Button, ButtonState)> + pub fn all_current(&self) -> impl Iterator<Item = (Button, ButtonState)> + use<'_> { self.map .iter() |
