Skip to content

Commit

Permalink
FRAME: Introduce ConvertToValue adapter (paritytech#14270)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork authored and nathanwhit committed Jul 19, 2023
1 parent fa33f29 commit bb3e182
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit bb3e182

Please sign in to comment.