fix unwrap errors

This commit is contained in:
Chance 2024-12-05 11:16:40 -05:00 committed by lily
parent 5d690f4ca9
commit e0cfbd0fd2
Signed by: lily
GPG key ID: 601F3263FBCBC4B9
5 changed files with 17 additions and 13 deletions

View file

@ -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)?)

View file

@ -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 })
})
}

View file

@ -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() }