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 YeungandOliver Tale-Yazdi authored and GitHub committed 2022-06-13 12:31:42 +00:00
1 parent 8c1865d2f2
commit 2d6b0ecc21
13 files changed
+2484 -2323

No files matched your search

@@ -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."]