mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 14:01:02 +00:00
refactor overseer into proc-macro based pattern (#2962)
This commit is contained in:
committed by
GitHub
parent
2510bfc5d7
commit
3c9104daff
@@ -0,0 +1,13 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use polkadot_overseer_all_subsystems_gen::AllSubsystemsGen;
|
||||
|
||||
#[derive(Clone, AllSubsystemsGen)]
|
||||
enum AllSubsystems<A,B> {
|
||||
A(A),
|
||||
B(B),
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let all = AllSubsystems::<u8,u16>::A(0u8);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: expected `struct`
|
||||
--> $DIR/err-01-enum.rs:6:1
|
||||
|
|
||||
6 | enum AllSubsystems<A,B> {
|
||||
| ^^^^
|
||||
@@ -0,0 +1,16 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use polkadot_overseer_all_subsystems_gen::AllSubsystemsGen;
|
||||
#[derive(Clone, AllSubsystemsGen)]
|
||||
struct AllSubsystems<X> {
|
||||
a: X,
|
||||
b: X,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let all = AllSubsystems::<u16> {
|
||||
a: 0_u16,
|
||||
b: 1_u16,
|
||||
};
|
||||
let _all = all.replace_a(77u8);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
error: Generic type parameters may only be used for exactly one field, but is used more than once.
|
||||
--> $DIR/err-01-generic-used-twice.rs:6:5
|
||||
|
|
||||
6 | a: X,
|
||||
| ^
|
||||
|
||||
error[E0599]: no method named `replace_a` found for struct `AllSubsystems<u16>` in the current scope
|
||||
--> $DIR/err-01-generic-used-twice.rs:15:17
|
||||
|
|
||||
5 | struct AllSubsystems<X> {
|
||||
| ----------------------- method `replace_a` not found for this
|
||||
...
|
||||
15 | let _all = all.replace_a(77u8);
|
||||
| ^^^^^^^^^ method not found in `AllSubsystems<u16>`
|
||||
@@ -0,0 +1,17 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use polkadot_overseer_all_subsystems_gen::AllSubsystemsGen;
|
||||
|
||||
#[derive(Clone, AllSubsystemsGen)]
|
||||
struct AllSubsystems {
|
||||
a: f32,
|
||||
b: u16,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let all = AllSubsystems {
|
||||
a: 0_f32,
|
||||
b: 1_u16,
|
||||
};
|
||||
let _all = all.replace_a(77u8);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
error: struct must have at least one generic parameter.
|
||||
--> $DIR/err-01-no-generic.rs:6:8
|
||||
|
|
||||
6 | struct AllSubsystems {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error[E0599]: no method named `replace_a` found for struct `AllSubsystems` in the current scope
|
||||
--> $DIR/err-01-no-generic.rs:16:17
|
||||
|
|
||||
6 | struct AllSubsystems {
|
||||
| -------------------- method `replace_a` not found for this
|
||||
...
|
||||
16 | let _all = all.replace_a(77u8);
|
||||
| ^^^^^^^^^ method not found in `AllSubsystems`
|
||||
@@ -0,0 +1,14 @@
|
||||
error: Generic type parameters may only be used once have at least one generic parameter.
|
||||
--> $DIR/err-01-no-generics.rs:7:5
|
||||
|
|
||||
7 | a: X,
|
||||
| ^
|
||||
|
||||
error[E0599]: no method named `replace_a` found for struct `AllSubsystems<u16>` in the current scope
|
||||
--> $DIR/err-01-no-generics.rs:16:17
|
||||
|
|
||||
6 | struct AllSubsystems<X> {
|
||||
| ----------------------- method `replace_a` not found for this
|
||||
...
|
||||
16 | let _all = all.replace_a(77u8);
|
||||
| ^^^^^^^^^ method not found in `AllSubsystems<u16>`
|
||||
@@ -0,0 +1,17 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use polkadot_overseer_all_subsystems_gen::AllSubsystemsGen;
|
||||
|
||||
#[derive(Clone, AllSubsystemsGen)]
|
||||
struct AllSubsystems<A, B> {
|
||||
a: A,
|
||||
b: B,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let all = AllSubsystems::<u8, u16> {
|
||||
a: 0u8,
|
||||
b: 1u16,
|
||||
};
|
||||
let _all: AllSubsystems<_,_> = all.replace_a::<u32>(777_777u32);
|
||||
}
|
||||
Reference in New Issue
Block a user