Move bounded type definitions to sp-runtime (#11645)

* Move bounded type definitions to sp-runtime

* cargo fmt

* Fix compile error

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Move TryCollect to sp-runtime

* Write some docs

* Import missing types

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Keith Yeung
2022-06-13 14:31:42 +02:00
committed by GitHub
parent 8c1865d2f2
commit 2d6b0ecc21
13 changed files with 2484 additions and 2323 deletions
@@ -308,6 +308,17 @@ impl<T: Default> Get<T> for GetDefault {
}
}
/// Try and collect into a collection `C`.
pub trait TryCollect<C> {
/// The error type that gets returned when a collection can't be made from `self`.
type Error;
/// Consume self and try to collect the results into `C`.
///
/// This is useful in preventing the undesirable `.collect().try_into()` call chain on
/// collections that need to be converted into a bounded type (e.g. `BoundedVec`).
fn try_collect(self) -> Result<C, Self::Error>;
}
macro_rules! impl_const_get {
($name:ident, $t:ty) => {
#[doc = "Const getter for a basic type."]