Skip to content

Commit

Permalink
Fix build with no_std
Browse files Browse the repository at this point in the history
  • Loading branch information
ogoffart committed Feb 14, 2022
1 parent 267a73b commit 7a7a21c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions internal/core/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
This module contains types that are public and re-exported in the slint-rs as well as the slint-interpreter crate as public API.
*/

use std::rc::Rc;
use alloc::boxed::Box;
use alloc::rc::Rc;

use crate::component::ComponentVTable;
use crate::window::WindowRc;
Expand All @@ -18,7 +19,7 @@ pub enum GraphicsAPI<'a> {
/// The rendering is done using OpenGL.
NativeOpenGL {
/// Use this function pointer to obtain access to the OpenGL implementation - similar to `eglGetProcAddress`.
get_proc_address: &'a dyn Fn(&str) -> *const std::ffi::c_void,
get_proc_address: &'a dyn Fn(&str) -> *const core::ffi::c_void,
},
/// The rendering is done on a HTML Canvas element using WebGL.
WebGL {
Expand All @@ -30,8 +31,8 @@ pub enum GraphicsAPI<'a> {
},
}

impl<'a> std::fmt::Debug for GraphicsAPI<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl<'a> core::fmt::Debug for GraphicsAPI<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
GraphicsAPI::NativeOpenGL { .. } => write!(f, "GraphicsAPI::NativeOpenGL"),
GraphicsAPI::WebGL { context_type, .. } => {
Expand Down Expand Up @@ -116,7 +117,7 @@ impl Window {
pub fn set_rendering_notifier(
&self,
callback: impl FnMut(RenderingState, &GraphicsAPI) + 'static,
) -> std::result::Result<(), SetRenderingNotifierError> {
) -> Result<(), SetRenderingNotifierError> {
self.0.set_rendering_notifier(Box::new(callback))
}

Expand Down
2 changes: 1 addition & 1 deletion internal/core/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ impl Model for bool {
pub struct ModelRc<T>(Option<Rc<dyn Model<Data = T>>>);

impl<T> core::fmt::Debug for ModelRc<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "ModelRc(dyn Model)")
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/core/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub trait PlatformWindow {
fn set_rendering_notifier(
&self,
_callback: Box<dyn crate::api::RenderingNotifier>,
) -> std::result::Result<(), crate::api::SetRenderingNotifierError> {
) -> Result<(), crate::api::SetRenderingNotifierError> {
Err(crate::api::SetRenderingNotifierError::Unsupported)
}

Expand Down

0 comments on commit 7a7a21c

Please sign in to comment.