fix unwrap errors
This commit is contained in:
parent
74cc9bccaa
commit
9c4d5f2769
5 changed files with 17 additions and 13 deletions
|
@ -6,7 +6,7 @@ use renderer::App;
|
|||
use winit::event_loop::{ControlFlow, EventLoop};
|
||||
|
||||
pub fn init_renderer() -> Result<()> {
|
||||
let event_loop = EventLoop::new().unwrap();
|
||||
let event_loop = EventLoop::new()?;
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
let mut app = App::default();
|
||||
Ok(event_loop.run_app(&mut app)?)
|
||||
|
|
|
@ -41,7 +41,9 @@ impl<'window> WgpuCtx<'window> {
|
|||
let width = size.width.max(1);
|
||||
let height = size.height.max(1);
|
||||
|
||||
let surface_config = surface.get_default_config(&adapter, width, height).unwrap();
|
||||
let surface_config = surface
|
||||
.get_default_config(&adapter, width, height)
|
||||
.expect("Failed to get default surface configuration");
|
||||
surface.configure(&device, &surface_config);
|
||||
|
||||
Ok(WgpuCtx {
|
||||
|
@ -55,9 +57,7 @@ impl<'window> WgpuCtx<'window> {
|
|||
|
||||
pub fn new_blocking(window: Arc<Window>) -> Result<WgpuCtx<'window>> {
|
||||
tokio::task::block_in_place(|| {
|
||||
tokio::runtime::Runtime::new()
|
||||
.unwrap()
|
||||
.block_on(async { WgpuCtx::new(window).await })
|
||||
tokio::runtime::Runtime::new()?.block_on(async { WgpuCtx::new(window).await })
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use std::{
|
||||
borrow::Cow::{self, Borrowed, Owned},
|
||||
sync::{Arc, Mutex},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
use chrono::Local;
|
||||
use colored::Colorize;
|
||||
use log::debug;
|
||||
use parking_lot::Mutex;
|
||||
use regex::Regex;
|
||||
use rustyline::{
|
||||
error::ReadlineError, highlight::Highlighter, hint::HistoryHinter, history::DefaultHistory,
|
||||
|
@ -49,7 +50,7 @@ impl ConditionalEventHandler for BacktickEventHandler {
|
|||
fn handle(&self, evt: &Event, _: RepeatCount, _: bool, _: &EventContext) -> Option<Cmd> {
|
||||
if let Some(k) = evt.get(0) {
|
||||
if *k == KeyEvent::from('`') {
|
||||
let mut state = self.toggle_state.lock().unwrap();
|
||||
let mut state = self.toggle_state.lock();
|
||||
println!(
|
||||
"Stdout Logging: {}",
|
||||
if *state { "ON".green() } else { "OFF".red() }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue