Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

FRAME: Introduce ConvertToValue adapter #14270

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions primitives/runtime/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down