[librsvg: 29/45] impl Default for Session




commit f6be4ee89e1f9ff463cde9da9dec5d74274d92da
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Aug 23 13:38:32 2022 -0500

    impl Default for Session
    
    Clippy had suggested this, but we'll need it to make things easy in c_api.
    
    Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/731>

 src/api.rs     | 2 +-
 src/session.rs | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/api.rs b/src/api.rs
index 02b123599..4c97955b4 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -59,7 +59,7 @@ impl Loader {
     ///     .unwrap();
     /// ```
     pub fn new() -> Self {
-        Self::new_with_session(Session::new())
+        Self::new_with_session(Session::default())
     }
 
     /// Creates a `Loader` from a pre-created [`Session`].
diff --git a/src/session.rs b/src/session.rs
index 87385aa8a..1f2b998b0 100644
--- a/src/session.rs
+++ b/src/session.rs
@@ -18,15 +18,17 @@ struct SessionInner {
     log_enabled: bool,
 }
 
-impl Session {
-    pub fn new() -> Self {
+impl Default for Session {
+    fn default() -> Self {
         Self {
             inner: Arc::new(SessionInner {
                 log_enabled: log::log_enabled(),
             }),
         }
     }
+}
 
+impl Session {
     #[cfg(test)]
     pub fn new_for_test_suite() -> Self {
         Self {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]