From cea8f9d56f62d8f6fcf2594d0a93f12ec2cfb3c5 Mon Sep 17 00:00:00 2001
From: Gavin Wood <gavin@parity.io>
Date: Thu, 1 Jun 2023 10:01:55 +0100
Subject: [PATCH] FRAME: Introduce `ConvertToValue` adapter (#14270)

---
 substrate/primitives/runtime/src/traits.rs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/substrate/primitives/runtime/src/traits.rs b/substrate/primitives/runtime/src/traits.rs
index d1fda9f3d52..a2af0b77804 100644
--- a/substrate/primitives/runtime/src/traits.rs
+++ b/substrate/primitives/runtime/src/traits.rs
@@ -530,6 +530,15 @@ impl<A, B: Default> Convert<A, B> for () {
 	}
 }
 
+/// Adapter which turns a `Get` implementation into a `Convert` implementation which always returns
+/// in the same value no matter the input.
+pub struct ConvertToValue<T>(sp_std::marker::PhantomData<T>);
+impl<X, Y, T: Get<Y>> Convert<X, Y> for ConvertToValue<T> {
+	fn convert(_: X) -> Y {
+		T::get()
+	}
+}
+
 /// A structure that performs identity conversion.
 pub struct Identity;
 impl<T> Convert<T, T> for Identity {
-- 
GitLab