From bb3e18245d1e17c98e7fe937277338f2ac1039a4 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Thu, 1 Jun 2023 10:01:55 +0100 Subject: [PATCH] FRAME: Introduce `ConvertToValue` adapter (#14270) --- primitives/runtime/src/traits.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/primitives/runtime/src/traits.rs b/primitives/runtime/src/traits.rs index d1fda9f3d5256..a2af0b778040b 100644 --- a/primitives/runtime/src/traits.rs +++ b/primitives/runtime/src/traits.rs @@ -530,6 +530,15 @@ impl Convert 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(sp_std::marker::PhantomData); +impl> Convert for ConvertToValue { + fn convert(_: X) -> Y { + T::get() + } +} + /// A structure that performs identity conversion. pub struct Identity; impl Convert for Identity {