1+ #![ allow( clippy:: needless_return) ]
2+
13use std:: env;
24
35use args:: {
@@ -121,16 +123,17 @@ struct Args {
121123 obj_path : String ,
122124}
123125
124- impl Into < Args > for Vec < ParsedArgument > {
125- fn into ( self ) -> Args {
126+ impl From < Vec < ParsedArgument > > for Args {
127+ fn from ( arguments : Vec < ParsedArgument > ) -> Args {
126128 let mut args = Args {
127129 obj_path : String :: new ( ) ,
128130 } ;
129131
130- for arg in self {
131- match ( arg. name ( ) . as_str ( ) , arg. value ( ) ) {
132- ( "--obj-path" , ArgumentValue :: String ( path) ) => args. obj_path = path,
133- ( _, _) => { }
132+ for arg in arguments {
133+ if let ( "--obj-path" , ArgumentValue :: String ( path) ) =
134+ ( arg. name ( ) . as_str ( ) , arg. value ( ) )
135+ {
136+ args. obj_path = path;
134137 }
135138 }
136139
@@ -149,7 +152,7 @@ fn parse_arguments() -> Args {
149152 . with_argument ( obj_file)
150153 . compile ( & env:: args ( ) . collect :: < Vec < _ > > ( ) ) ;
151154
152- return args . into ( ) ;
155+ return Args :: from ( args ) ;
153156}
154157
155158struct ObjLoader {
@@ -170,13 +173,10 @@ impl Component<ComponentResult, String> for ObjLoader {
170173 }
171174
172175 fn on_window_event ( & mut self , event : & WindowEvent ) -> Result < ( ) , String > {
173- match event {
174- WindowEvent :: Resize { width, height } => {
175- self . width = * width;
176- self . height = * height;
177- logging:: info!( "Window resized to {}x{}" , width, height) ;
178- }
179- _ => { }
176+ if let WindowEvent :: Resize { width, height } = event {
177+ self . width = * width;
178+ self . height = * height;
179+ logging:: info!( "Window resized to {}x{}" , width, height) ;
180180 }
181181 return Ok ( ( ) ) ;
182182 }
@@ -263,21 +263,20 @@ impl Component<ComponentResult, String> for ObjLoader {
263263 viewports: vec![ viewport. clone( ) ] ,
264264 } ,
265265 RenderCommand :: SetPipeline {
266- pipeline: render_pipeline. clone ( ) ,
266+ pipeline: render_pipeline,
267267 } ,
268268 RenderCommand :: BeginRenderPass {
269269 render_pass: self
270270 . render_pass
271- . expect( "Cannot begin the render pass when it doesn't exist." )
272- . clone( ) ,
271+ . expect( "Cannot begin the render pass when it doesn't exist." ) ,
273272 viewport: viewport. clone( ) ,
274273 } ,
275274 RenderCommand :: BindVertexBuffer {
276- pipeline: render_pipeline. clone ( ) ,
275+ pipeline: render_pipeline,
277276 buffer: 0 ,
278277 } ,
279278 RenderCommand :: Immediates {
280- pipeline: render_pipeline. clone ( ) ,
279+ pipeline: render_pipeline,
281280 offset: 0 ,
282281 bytes: Vec :: from( immediate_data_to_bytes( & ImmediateData {
283282 data: [ 0.0 , 0.0 , 0.0 , 0.0 ] ,
0 commit comments