summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilal Elmoussaoui <belmouss@redhat.com>2022-07-23 09:28:12 +0200
committerBilal Elmoussaoui <belmouss@redhat.com>2022-07-23 09:28:12 +0200
commit5c20f4905aa871e7abbf0199eb3434ce007dc763 (patch)
tree34cf95fac092dbdc79347d83b35e70cedaed4f82
parent5818fe3f85b60a908b2be574ea26875ed47bff85 (diff)
downloadlibrsvg-bilelmoussaoui/param-spec.tar.gz
c-api: Use derive Default for ObjectSubclass statebilelmoussaoui/param-spec
By default the attribute macro object_subclass uses T::default inside the new method implementation Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/721>
-rw-r--r--src/c_api/handle.rs21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/c_api/handle.rs b/src/c_api/handle.rs
index 3f2fafad..549bcede 100644
--- a/src/c_api/handle.rs
+++ b/src/c_api/handle.rs
@@ -208,6 +208,12 @@ impl LoadState {
}
}
+impl Default for LoadState {
+ fn default() -> Self {
+ Self::Start
+ }
+}
+
/// Holds the base URL for loading a handle, and the C-accessible version of it
///
/// There is a public API to query the base URL, and we need to
@@ -287,11 +293,13 @@ mod imp {
/// Contains all the interior mutability for a RsvgHandle to be called
/// from the C API.
+ #[derive(Default)]
pub struct CHandle {
pub(super) inner: RefCell<CHandleInner>,
pub(super) load_state: RefCell<LoadState>,
}
+ #[derive(Default)]
pub(super) struct CHandleInner {
pub(super) dpi: Dpi,
pub(super) load_flags: LoadFlags,
@@ -308,19 +316,6 @@ mod imp {
type Instance = RsvgHandle;
type Class = RsvgHandleClass;
-
- fn new() -> Self {
- CHandle {
- inner: RefCell::new(CHandleInner {
- dpi: Dpi::default(),
- load_flags: LoadFlags::default(),
- base_url: BaseUrl::default(),
- size_callback: SizeCallback::default(),
- is_testing: false,
- }),
- load_state: RefCell::new(LoadState::Start),
- }
- }
}
impl ObjectImpl for CHandle {