mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
Introduce EnsureOrigin::try_successul_origin (#11558)
* Introduce `EnsureOrigin::try_successul_origin` * Formatting * Fixes * Add Morph * Fixes * Formatting
This commit is contained in:
@@ -274,6 +274,42 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Extensible conversion trait. Generic over only source type, with destination type being
|
||||
/// associated.
|
||||
pub trait Morph<A> {
|
||||
/// The type into which `A` is mutated.
|
||||
type Outcome;
|
||||
|
||||
/// Make conversion.
|
||||
fn morph(a: A) -> Self::Outcome;
|
||||
}
|
||||
|
||||
/// A structure that performs identity conversion.
|
||||
impl<T> Morph<T> for Identity {
|
||||
type Outcome = T;
|
||||
fn morph(a: T) -> T {
|
||||
a
|
||||
}
|
||||
}
|
||||
|
||||
/// Extensible conversion trait. Generic over only source type, with destination type being
|
||||
/// associated.
|
||||
pub trait TryMorph<A> {
|
||||
/// The type into which `A` is mutated.
|
||||
type Outcome;
|
||||
|
||||
/// Make conversion.
|
||||
fn try_morph(a: A) -> Result<Self::Outcome, ()>;
|
||||
}
|
||||
|
||||
/// A structure that performs identity conversion.
|
||||
impl<T> TryMorph<T> for Identity {
|
||||
type Outcome = T;
|
||||
fn try_morph(a: T) -> Result<T, ()> {
|
||||
Ok(a)
|
||||
}
|
||||
}
|
||||
|
||||
/// Extensible conversion trait. Generic over both source and destination types.
|
||||
pub trait Convert<A, B> {
|
||||
/// Make conversion.
|
||||
|
||||
Reference in New Issue
Block a user