AsRef < Deref
This commit is contained in:
parent
3157fbdac1
commit
bdb746c861
|
@ -51,13 +51,13 @@ impl MyEmulator {
|
|||
let raw_retro = retro::loading::LibretroApi::from_library(lib).unwrap();
|
||||
let retro = retro::wrapper::LibretroWrapper::from(raw_retro);
|
||||
|
||||
let sys_info = retro.as_ref().get_system_info();
|
||||
let sys_info = retro.get_system_info();
|
||||
let title = format!(
|
||||
"{} - rust libretro",
|
||||
unsafe { CStr::from_ptr(sys_info.library_name) }.to_string_lossy()
|
||||
);
|
||||
|
||||
let mut av_info = retro.as_ref().get_system_av_info();
|
||||
let mut av_info = retro.get_system_av_info();
|
||||
let pixel_format = sdl2::pixels::PixelFormatEnum::ABGR1555;
|
||||
|
||||
// HACK: some cores don't report this 'til we get an environ call to set_system_av_info...
|
||||
|
@ -130,7 +130,7 @@ impl MyEmulator {
|
|||
};
|
||||
let mut pin_emu = Box::pin(emu);
|
||||
retro::wrapper::set_handler(pin_emu.as_mut());
|
||||
pin_emu.retro.as_ref().init();
|
||||
pin_emu.retro.init();
|
||||
pin_emu
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ impl MyEmulator {
|
|||
}
|
||||
|
||||
// The rest of the game loop goes here...
|
||||
self.retro.as_ref().run();
|
||||
self.retro.run();
|
||||
self.canvas.present();
|
||||
|
||||
Duration::from_secs_f64(1.0 / self.av_info.timing.fps)
|
||||
|
@ -173,7 +173,6 @@ impl MyEmulator {
|
|||
}
|
||||
}
|
||||
self.retro
|
||||
.as_ref()
|
||||
.load_game(Some(path), data, None)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ use core::ffi::c_void;
|
|||
use core::slice::from_raw_parts;
|
||||
|
||||
use std::ffi::{CString, CStr};
|
||||
use std::ops::Deref;
|
||||
use std::os::raw::{c_uint, c_char};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::pin::Pin;
|
||||
|
@ -226,8 +227,9 @@ impl From<LibretroApi> for LibretroWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
impl AsRef<LibretroApi> for LibretroWrapper {
|
||||
fn as_ref(&self) -> &LibretroApi {
|
||||
impl Deref for LibretroWrapper {
|
||||
type Target = LibretroApi;
|
||||
fn deref(&self) -> &LibretroApi {
|
||||
&self.api
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue