From 6d5f793718fa4513ded105d33bfc6f080105aa7b Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Mon, 18 Nov 2019 20:30:17 +0000 Subject: [PATCH] util: Include Result logger --- src/style.rs | 17 +---------------- src/util.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/style.rs b/src/style.rs index bead76da..b8f147a7 100644 --- a/src/style.rs +++ b/src/style.rs @@ -21,6 +21,7 @@ use std::env; use glib::object::ObjectExt; +use util::Warn; /// Gathers stuff defined in C or called by C pub mod c { @@ -61,22 +62,6 @@ pub mod c { // not Adwaita, but rather fall back to default const DEFAULT_THEME_NAME: &str = ""; -/// Sugar for logging errors in results -trait Warn { - type Value; - fn ok_warn(self, msg: &str) -> Option; -} - -impl Warn for Result { - type Value = T; - fn ok_warn(self, msg: &str) -> Option { - self.map_err(|e| { - eprintln!("{}: {}", msg, e); - e - }).ok() - } -} - struct GtkTheme { name: String, variant: Option, diff --git a/src/util.rs b/src/util.rs index 1a86330d..891e9d28 100644 --- a/src/util.rs +++ b/src/util.rs @@ -177,6 +177,22 @@ impl Borrow> for Pointer { } } +/// Sugar for logging errors in results +pub trait Warn { + type Value; + fn ok_warn(self, msg: &str) -> Option; +} + +impl Warn for Result { + type Value = T; + fn ok_warn(self, msg: &str) -> Option { + self.map_err(|e| { + eprintln!("{}: {}", msg, e); + e + }).ok() + } +} + pub trait WarningHandler { /// Handle a warning fn handle(&mut self, warning: &str);