Repository: paritytech/substrate
File: frame/system/src/lib.rs (Rust)

Code before:
			RawOrigin::None => Ok(()),
			r => Err(O::from(r)),
		})
	}

	#[cfg(feature = "runtime-benchmarks")]
	fn successful_origin() -> O {
		O::from(RawOrigin::None)
	}
}

pub struct EnsureNever<T>(sp_std::marker::PhantomData<T>);
impl<O, T> EnsureOrigin<O> for EnsureNever<T> {
	type Success = T;
	fn try_origin(o: O) -> Result<Self::Success, O> {
		Err(o)
	}

	#[cfg(feature = "runtime-benchmarks")]
	fn successful_origin() -> O {
		unimplemented!()
	}
}

/// The "OR gate" implementation of `EnsureOrigin`. Origin check would pass if any of `L`'s or
/// `R`'s origin check passes.
pub struct EnsureOneOf<AccountId, L, R>(sp_std::marker::PhantomData<(AccountId, L, R)>);
impl<
	AccountId,
	O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>>,
	L: EnsureOrigin<O>,
	R: EnsureOrigin<O>,
> EnsureOrigin<O> for EnsureOneOf<AccountId, L, R> {
	type Success = Either<L::Success, R::Success>;
	fn try_origin(o: O) -> Result<Self::Success, O> {
		L::try_origin(o).map_or_else(
			|o| R::try_origin(o).map(|o| Either::Right(o)),
			|o| Ok(Either::Left(o)),
		)
	}

	#[cfg(feature = "runtime-benchmarks")]
	fn successful_origin() -> O {
		L::successful_origin()
	}
}

/// Ensure that the origin `o` represents a signed extrinsic (i.e. transaction).
/// Returns `Ok` with the account that signed the extrinsic or an `Err` otherwise.
pub fn ensure_signed<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<AccountId, BadOrigin>
	where OuterOrigin: Into<Result<RawOrigin<AccountId>, OuterOrigin>>

Review comment (suggestion):
```suggestion
/// The "OR gate" implementation of `EnsureOrigin`. 
///
/// Origin check will pass if `L` or `R` origin check passes. `L` is tested first.
```

Code after:
			RawOrigin::None => Ok(()),
			r => Err(O::from(r)),
		})
	}

	#[cfg(feature = "runtime-benchmarks")]
	fn successful_origin() -> O {
		O::from(RawOrigin::None)
	}
}

pub struct EnsureNever<T>(sp_std::marker::PhantomData<T>);
impl<O, T> EnsureOrigin<O> for EnsureNever<T> {
	type Success = T;
	fn try_origin(o: O) -> Result<Self::Success, O> {
		Err(o)
	}

	#[cfg(feature = "runtime-benchmarks")]
	fn successful_origin() -> O {
		unimplemented!()
	}
}

/// The "OR gate" implementation of `EnsureOrigin`.
///
/// Origin check will pass if `L` or `R` origin check passes. `L` is tested first.
pub struct EnsureOneOf<AccountId, L, R>(sp_std::marker::PhantomData<(AccountId, L, R)>);
impl<
	AccountId,
	O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>>,
	L: EnsureOrigin<O>,
	R: EnsureOrigin<O>,
> EnsureOrigin<O> for EnsureOneOf<AccountId, L, R> {
	type Success = Either<L::Success, R::Success>;
	fn try_origin(o: O) -> Result<Self::Success, O> {
		L::try_origin(o).map_or_else(
			|o| R::try_origin(o).map(|o| Either::Right(o)),
			|o| Ok(Either::Left(o)),
		)
	}

	#[cfg(feature = "runtime-benchmarks")]
	fn successful_origin() -> O {
		L::successful_origin()
	}
}

/// Ensure that the origin `o` represents a signed extrinsic (i.e. transaction).
/// Returns `Ok` with the account that signed the extrinsic or an `Err` otherwise.
pub fn ensure_signed<OuterOrigin, AccountId>(o: OuterOrigin) -> Result<AccountId, BadOrigin>