[librsvg: 34/53] Use a single unsafe block




commit 356b5d3ea28968f5950f290368945fc17268c01a
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Oct 21 19:00:05 2020 -0500

    Use a single unsafe block

 tests/src/utils.rs | 52 +++++++++++++++++++++++++---------------------------
 1 file changed, 25 insertions(+), 27 deletions(-)
---
diff --git a/tests/src/utils.rs b/tests/src/utils.rs
index 91b8d1fb..7d8b613f 100644
--- a/tests/src/utils.rs
+++ b/tests/src/utils.rs
@@ -30,45 +30,43 @@ pub fn setup_font_map() {
     use glib::prelude::*;
     use pangocairo::FontMap;
 
-    let font_paths = [
-        "tests/resources/Roboto-Regular.ttf",
-        "tests/resources/Roboto-Italic.ttf",
-        "tests/resources/Roboto-Bold.ttf",
-        "tests/resources/Roboto-BoldItalic.ttf",
-    ];
+    unsafe {
+        let font_paths = [
+            "tests/resources/Roboto-Regular.ttf",
+            "tests/resources/Roboto-Italic.ttf",
+            "tests/resources/Roboto-Bold.ttf",
+            "tests/resources/Roboto-BoldItalic.ttf",
+        ];
 
-    let config = unsafe { fontconfig::FcConfigCreate() };
+        let config = fontconfig::FcConfigCreate();
 
-    for path in &font_paths {
-        let path = fixture_path(path);
-        let str = path.to_str().unwrap();
+        for path in &font_paths {
+            let path = fixture_path(path);
+            let str = path.to_str().unwrap();
 
-        unsafe {
             if fontconfig::FcConfigAppFontAddFile(config, str.as_ptr()) == 0 {
                 panic!("Could not load font file {} for tests; aborting", str);
             }
-        };
-    }
+        }
 
-    let font_map = FontMap::new_for_font_type(cairo::FontType::FontTypeFt).unwrap();
-    let raw_font_map: *mut pango_sys::PangoFontMap = font_map.to_glib_none().0;
+        let font_map = FontMap::new_for_font_type(cairo::FontType::FontTypeFt).unwrap();
+        let raw_font_map: *mut pango_sys::PangoFontMap = font_map.to_glib_none().0;
 
-    extern "C" {
-        // pango_fc_font_map_set_config (PangoFcFontMap *fcfontmap,
-       //                               FcConfig       *fcconfig);
-        // This is not bound in gtk-rs, and PangoFcFontMap is not even exposed, so we'll bind it by hand.
-        fn pango_fc_font_map_set_config(
-            font_map: *mut libc::c_void,
-            config: *mut fontconfig::FcConfig,
-        );
-    }
+        extern "C" {
+            // pango_fc_font_map_set_config (PangoFcFontMap *fcfontmap,
+           //                               FcConfig       *fcconfig);
+            // This is not bound in gtk-rs, and PangoFcFontMap is not even exposed, so we'll bind it by hand.
+            fn pango_fc_font_map_set_config(
+                font_map: *mut libc::c_void,
+                config: *mut fontconfig::FcConfig,
+            );
+        }
 
-    unsafe {
         pango_fc_font_map_set_config (raw_font_map as *mut _, config);
         fontconfig::FcConfigDestroy(config);
-    };
 
-    FontMap::set_default(Some(font_map.downcast::<pangocairo::FontMap>().unwrap()));
+        FontMap::set_default(Some(font_map.downcast::<pangocairo::FontMap>().unwrap()));
+    }
 }
 
 #[cfg(not(have_pangoft2))]


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