@@ -214,22 +214,20 @@ impl Component<ComponentResult, String> for ReflectiveRoomExample {
214214 }
215215
216216 fn on_window_event ( & mut self , event : & WindowEvent ) -> Result < ( ) , String > {
217- match event {
218- WindowEvent :: Resize { width, height } => {
219- self . width = * width;
220- self . height = * height;
221- }
222- _ => { }
217+ if let WindowEvent :: Resize { width, height } = event {
218+ self . width = * width;
219+ self . height = * height;
223220 }
224221 return Ok ( ( ) ) ;
225222 }
226223
227224 fn on_keyboard_event ( & mut self , event : & Key ) -> Result < ( ) , String > {
228- match event {
229- Key :: Pressed {
230- scan_code : _,
231- virtual_key,
232- } => match virtual_key {
225+ if let Key :: Pressed {
226+ scan_code : _,
227+ virtual_key,
228+ } = event
229+ {
230+ match virtual_key {
233231 Some ( VirtualKey :: KeyM ) => {
234232 self . msaa_samples = if self . msaa_samples > 1 { 1 } else { 4 } ;
235233 self . needs_rebuild = true ;
@@ -272,8 +270,7 @@ impl Component<ComponentResult, String> for ReflectiveRoomExample {
272270 ) ;
273271 }
274272 _ => { }
275- } ,
276- _ => { }
273+ }
277274 }
278275 return Ok ( ( ) ) ;
279276 }
@@ -625,9 +622,7 @@ impl ReflectiveRoomExample {
625622 . with_immediate_data ( immediate_data_size)
626623 . with_buffer (
627624 BufferBuilder :: new ( )
628- . with_length (
629- floor_mesh. vertices ( ) . len ( ) * std:: mem:: size_of :: < Vertex > ( ) ,
630- )
625+ . with_length ( std:: mem:: size_of_val ( floor_mesh. vertices ( ) ) )
631626 . with_usage ( Usage :: VERTEX )
632627 . with_properties ( Properties :: DEVICE_LOCAL )
633628 . with_buffer_type ( BufferType :: Vertex )
@@ -677,9 +672,7 @@ impl ReflectiveRoomExample {
677672 . with_immediate_data ( immediate_data_size)
678673 . with_buffer (
679674 BufferBuilder :: new ( )
680- . with_length (
681- cube_mesh. vertices ( ) . len ( ) * std:: mem:: size_of :: < Vertex > ( ) ,
682- )
675+ . with_length ( std:: mem:: size_of_val ( cube_mesh. vertices ( ) ) )
683676 . with_usage ( Usage :: VERTEX )
684677 . with_properties ( Properties :: DEVICE_LOCAL )
685678 . with_buffer_type ( BufferType :: Vertex )
@@ -730,9 +723,7 @@ impl ReflectiveRoomExample {
730723 . with_immediate_data ( immediate_data_size)
731724 . with_buffer (
732725 BufferBuilder :: new ( )
733- . with_length (
734- floor_mesh. vertices ( ) . len ( ) * std:: mem:: size_of :: < Vertex > ( ) ,
735- )
726+ . with_length ( std:: mem:: size_of_val ( floor_mesh. vertices ( ) ) )
736727 . with_usage ( Usage :: VERTEX )
737728 . with_properties ( Properties :: DEVICE_LOCAL )
738729 . with_buffer_type ( BufferType :: Vertex )
@@ -768,9 +759,7 @@ impl ReflectiveRoomExample {
768759 . with_immediate_data ( immediate_data_size)
769760 . with_buffer (
770761 BufferBuilder :: new ( )
771- . with_length (
772- cube_mesh. vertices ( ) . len ( ) * std:: mem:: size_of :: < Vertex > ( ) ,
773- )
762+ . with_length ( std:: mem:: size_of_val ( cube_mesh. vertices ( ) ) )
774763 . with_usage ( Usage :: VERTEX )
775764 . with_properties ( Properties :: DEVICE_LOCAL )
776765 . with_buffer_type ( BufferType :: Vertex )
0 commit comments