From 3ff08d747c40c2fa744483af8717173c6e97cedd Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 21 Sep 2015 09:57:35 +0200 Subject: [PATCH] Add GlAttributes::map_sharing --- src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 4cf9b0d2..a5155f9c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -629,6 +629,20 @@ pub struct GlAttributes { pub vsync: bool, } +impl GlAttributes { + /// Turns the `sharing` parameter into another type by calling a closure. + pub fn map_sharing(self, f: F) -> GlAttributes where F: FnOnce(S) -> T { + GlAttributes { + sharing: self.sharing.map(f), + version: self.version, + profile: self.profile, + debug: self.debug, + robustness: self.robustness, + vsync: self.vsync, + } + } +} + impl Default for GlAttributes { fn default() -> GlAttributes { GlAttributes {