From 67257ab05256ebebd2e2d2e76700e8a91c82580d Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 18 Dec 2024 12:08:22 -0800 Subject: [PATCH] Add `SimpleGlobal::from_bound` method to construct from proxy object This seems a bit more convenient than defining a type and manually implementing `ProvidesBoundGlobal`. (I wonder if the API of `ProvidesBoundGlobal` and such could be improved, but this fits with what's already present.) --- src/registry.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/registry.rs b/src/registry.rs index 53fb4785e..24aed3ecb 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -402,6 +402,13 @@ impl SimpleGlobal { pub fn with_min_version(&self, min_version: u32) -> Result<&I, GlobalError> { self.proxy.with_min_version(min_version) } + + /// Construct an instance from an already bound proxy. + /// + /// Useful when a [`ProvidesBoundGlobal`] implementation is needed. + pub fn from_bound(proxy: I) -> Self { + Self { proxy: GlobalProxy::Bound(proxy) } + } } impl ProvidesBoundGlobal