Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The format feature is unavailable in nested code #6443

Closed
Ross249 opened this issue Jan 13, 2025 · 0 comments
Closed

The format feature is unavailable in nested code #6443

Ross249 opened this issue Jan 13, 2025 · 0 comments

Comments

@Ross249
Copy link

Ross249 commented Jan 13, 2025

My code can not be formatted by the command cargo fmt

An example of code is below

event_loop
        .run(move |event, control_flow| {
            match event {
                Event::DeviceEvent {
                                event: DeviceEvent::MouseMotion{ delta, },
                                .. 
                            } => if state.mouse_pressed {
                                state.camera_controller.process_mouse(delta.0, delta.1)
                            }
                Event::WindowEvent {
                    ref event,
                    window_id,
                } if window_id == state.window().id() => {
                    if !state.input(event) {
                        match event {
                            WindowEvent::CloseRequested
                            | WindowEvent::KeyboardInput {
                                event:
                                    KeyEvent {
                                        state: ElementState::Pressed,
                                        physical_key: PhysicalKey::Code(KeyCode::Escape),
                                        ..
                                    },
                                ..
                            } => control_flow.exit(),
                            WindowEvent::Resized(physical_size) => {
                                state.resize(*physical_size);
                            }
                            // The codes below are unformattable
                            WindowEvent::RedrawRequested => {
                                state.window().request_redraw();
                                        let now = instant::Instant::now();
                                        let dt = now - last_render_time;
                                    last_render_time = now;
                                        state.update(dt);
                                        match state.render() {
                                            Ok(_) => {}
                                            
                                            Err(wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated) => state.resize(state.size),
                                            
                                            Err(wgpu::SurfaceError::OutOfMemory) => control_flow.exit(),
                                            
                                            Err(wgpu::SurfaceError::Timeout) => log::warn!("Surface timeout"),
                                        }
                            }
                            _ => {}
                        }
                    }
                }
                _ => {}
            }
        })
        .unwrap();
@ytmimi ytmimi closed this as completed Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants