Implement Debug for svg/ types
@@ -3,9 +3,12 @@ use crate::prelude::*;
use crate::{Data, Rect};
use skia_bindings as sb;
use skia_bindings::SkCanvas;
-use std::ops::{Deref, DerefMut};
use std::pin::Pin;
use std::ptr;
+use std::{
+ fmt,
+ ops::{Deref, DerefMut},
+};
pub struct Canvas {
canvas: *mut SkCanvas,
@@ -24,7 +27,7 @@ impl Deref for Canvas {
type Target = crate::Canvas;
fn deref(&self) -> &Self::Target {
- crate::Canvas::borrow_from_native(unsafe { &mut *self.canvas })
+ crate::Canvas::borrow_from_native(unsafe { &*self.canvas })
}
}
@@ -42,6 +45,18 @@ bitflags! {
}
}
+impl fmt::Debug for Canvas {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.debug_struct("Canvas")
+ .field(
+ "canvas",
+ crate::Canvas::borrow_from_native(unsafe { &*self.canvas }),
+ )
+ .field("stream", &self.stream)
+ .finish()
+ }
+}
+
impl Canvas {
/// Creates a new SVG canvas.
pub fn new(bounds: impl AsRef<Rect>, flags: impl Into<Option<Flags>>) -> Canvas {
