FRAME: Introduce ConvertToValue adapter (#14270)

This commit is contained in:
Gavin Wood
2023-06-01 10:01:55 +01:00
committed by GitHub
parent 688ac3d1c7
commit cea8f9d56f
@@ -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 {