switched to using usings

This commit is contained in:
Jack Mac 2021-09-21 12:46:17 -04:00
parent 42e482138f
commit 31cc4b3df0

View File

@ -4,12 +4,7 @@
pub extern crate imgui_sys as sys; pub extern crate imgui_sys as sys;
use std::cell;
use std::ffi::CStr;
use std::os::raw::{c_char, c_void}; use std::os::raw::{c_char, c_void};
use std::ptr;
use std::str;
use std::thread;
pub use self::clipboard::*; pub use self::clipboard::*;
pub use self::color::ImColor32; pub use self::color::ImColor32;
@ -96,8 +91,8 @@ pub use core as __core;
#[doc(alias = "GetVersion")] #[doc(alias = "GetVersion")]
pub fn dear_imgui_version() -> &'static str { pub fn dear_imgui_version() -> &'static str {
unsafe { unsafe {
let bytes = CStr::from_ptr(sys::igGetVersion()).to_bytes(); let bytes = std::ffi::CStr::from_ptr(sys::igGetVersion()).to_bytes();
str::from_utf8_unchecked(bytes) std::str::from_utf8_unchecked(bytes)
} }
} }
@ -122,9 +117,9 @@ impl Context {
#[derive(Debug)] #[derive(Debug)]
pub struct Ui<'ui> { pub struct Ui<'ui> {
ctx: &'ui Context, ctx: &'ui Context,
font_atlas: Option<cell::RefMut<'ui, SharedFontAtlas>>, font_atlas: Option<std::cell::RefMut<'ui, SharedFontAtlas>>,
// imgui isn't mutli-threaded -- so no one will ever access twice. // imgui isn't mutli-threaded -- so no one will ever access twice.
buffer: cell::UnsafeCell<string::UiBuffer>, buffer: std::cell::UnsafeCell<string::UiBuffer>,
} }
impl<'ui> Ui<'ui> { impl<'ui> Ui<'ui> {
@ -199,7 +194,7 @@ impl<'ui> Ui<'ui> {
impl<'a> Drop for Ui<'a> { impl<'a> Drop for Ui<'a> {
#[doc(alias = "EndFrame")] #[doc(alias = "EndFrame")]
fn drop(&mut self) { fn drop(&mut self) {
if !thread::panicking() { if !std::thread::panicking() {
unsafe { unsafe {
sys::igEndFrame(); sys::igEndFrame();
} }
@ -246,7 +241,7 @@ impl<'ui> Ui<'ui> {
/// Renders a style editor block (not a window) for the currently active style /// Renders a style editor block (not a window) for the currently active style
#[doc(alias = "ShowStyleEditor")] #[doc(alias = "ShowStyleEditor")]
pub fn show_default_style_editor(&self) { pub fn show_default_style_editor(&self) {
unsafe { sys::igShowStyleEditor(ptr::null_mut()) }; unsafe { sys::igShowStyleEditor(std::ptr::null_mut()) };
} }
/// Renders a basic help/info block (not a window) /// Renders a basic help/info block (not a window)
#[doc(alias = "ShowUserGuide")] #[doc(alias = "ShowUserGuide")]