Associated type bounds is stabilized: rust-lang/rust#122055
So we can do code like this:
#![feature(associated_type_bounds)]
trait Foo: Bar<B: Default> {
}
trait Bar {
type B;
}
fn f<T: Foo>() {
<<T as Bar>::B as Default>::default();
}
Instead of doing this:
trait Foo: Bar<B> {
type B: IsType<Bar::B> + Default;
}
trait Bar {
type B;
}
fn f<T: Foo>() {
// Do back and forth conversion between <T as Foo>::B and <T as Bar>::B
}
1: simplify Config definition
So for pallets other than frame_system we no longer need the associated types: RuntimeEvent, RuntimeOrigin, RuntimeCall, etc...
Instead we should be able to modify the pallet Config trait definition like this:
#[pallet::config]
- pub trait Config: frame_system::Config {
- /// Overarching event type.
- type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
-
+ pub trait Config: frame_system::Config<RuntimeEvent: From<Event<Self>>> {
/// The type in which the assets for swapping are measured.
type Balance: Balance;
2: extend Config definition
We should be able to add constraint on pallet dependencies way more easily without having to write where ... for each implementation block.
To illustrate we could have a pallet which depends on pallet_balances but requires at least u128 as currency type
#[pallet::config]
pub trait Config: pallet_balances::Config<Balance: From<u128>> {
}
Associated type bounds is stabilized: rust-lang/rust#122055
So we can do code like this:
Instead of doing this:
1: simplify
ConfigdefinitionSo for pallets other than
frame_systemwe no longer need the associated types:RuntimeEvent,RuntimeOrigin,RuntimeCall, etc...Instead we should be able to modify the pallet
Configtrait definition like this:2: extend
ConfigdefinitionWe should be able to add constraint on pallet dependencies way more easily without having to write
where ...for each implementation block.To illustrate we could have a pallet which depends on
pallet_balancesbut requires at least u128 as currency type