Fix clippy lint and fmt in the emulator

This commit is contained in:
Gwilym Inzani 2024-04-09 20:55:21 +01:00
parent 52ddd97a2e
commit 08ad8765de
2 changed files with 12 additions and 7 deletions

View file

@ -15,7 +15,6 @@ pub enum LogLevel {
Unknown, Unknown,
} }
#[derive(Debug, Error)] #[derive(Debug, Error)]
#[error("A log level of {provided_log_level} does not match any known log level")] #[error("A log level of {provided_log_level} does not match any known log level")]
pub struct LogLevelIsNotValid { pub struct LogLevelIsNotValid {
@ -34,9 +33,11 @@ impl TryFrom<mgba_sys::mLogLevel> for LogLevel {
mgba_sys::mLogLevel_mLOG_DEBUG => LogLevel::Debug, mgba_sys::mLogLevel_mLOG_DEBUG => LogLevel::Debug,
mgba_sys::mLogLevel_mLOG_STUB => LogLevel::Stub, mgba_sys::mLogLevel_mLOG_STUB => LogLevel::Stub,
mgba_sys::mLogLevel_mLOG_GAME_ERROR => LogLevel::GameError, mgba_sys::mLogLevel_mLOG_GAME_ERROR => LogLevel::GameError,
_ => return Err(LogLevelIsNotValid { _ => {
provided_log_level: value return Err(LogLevelIsNotValid {
provided_log_level: value,
}) })
}
}) })
} }
} }
@ -95,7 +96,11 @@ extern "C" fn log_string_wrapper(
unsafe { CStr::from_ptr(category_c_name).to_str() }.unwrap_or(UNKNOWN) unsafe { CStr::from_ptr(category_c_name).to_str() }.unwrap_or(UNKNOWN)
}; };
logger(category_name, LogLevel::try_from(level).unwrap_or(LogLevel::Unknown), s); logger(
category_name,
LogLevel::try_from(level).unwrap_or(LogLevel::Unknown),
s,
);
} }
} }
} }

View file

@ -113,14 +113,14 @@ impl<V: VFile> VFileAlloc<V> {
} }
pub(crate) fn into_mgba(self) -> *mut mgba_sys::VFile { pub(crate) fn into_mgba(self) -> *mut mgba_sys::VFile {
let f = Box::into_raw(self.0) as *mut VFileInner<V>; let f = Box::into_raw(self.0);
f.cast() f.cast()
} }
} }
mod vfile_extern { mod vfile_extern {
use std::io::SeekFrom;
use super::VFileExtensions; use super::VFileExtensions;
use std::io::SeekFrom;
/// Safety: Must be part of a VFileInner /// Safety: Must be part of a VFileInner
pub unsafe fn create_vfile<V: super::VFile>() -> mgba_sys::VFile { pub unsafe fn create_vfile<V: super::VFile>() -> mgba_sys::VFile {