mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-24 15:57:58 +00:00
Retain Rust code items from mod decorated with subxt attribute (#721)
* refactor: Simplify collecting type substitutes * Simplify ItemMod::from * Preserve inner Rust items when expanding the subxt::subxt macro * No named lifetimes * Update codegen/src/api/mod.rs Co-authored-by: Andrew Jones <ascjones@gmail.com> * Move passing UI tests under `ui_tests` Co-authored-by: Andrew Jones <ascjones@gmail.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#[subxt::subxt(runtime_metadata_path = "../../../artifacts/polkadot_metadata.scale")]
|
||||
pub mod node_runtime {
|
||||
pub struct SomeStruct;
|
||||
pub enum SomeEnum {
|
||||
A,
|
||||
B,
|
||||
}
|
||||
pub trait SomeTrait {
|
||||
fn some_func(&self) -> u32;
|
||||
}
|
||||
impl SomeTrait for SomeStruct {
|
||||
fn some_func(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
}
|
||||
impl SomeTrait for SomeEnum {
|
||||
fn some_func(&self) -> u32 {
|
||||
2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
use node_runtime::SomeTrait;
|
||||
|
||||
let unit = node_runtime::SomeStruct;
|
||||
assert_eq!(unit.some_func(), 1);
|
||||
let enumeration = node_runtime::SomeEnum::A;
|
||||
assert_eq!(enumeration.some_func(), 2);
|
||||
}
|
||||
@@ -25,6 +25,8 @@ fn ui_tests() {
|
||||
let mut m = MetadataTestRunner::default();
|
||||
let t = trybuild::TestCases::new();
|
||||
|
||||
t.pass("src/correct/*.rs");
|
||||
|
||||
// Check that storage maps with no keys are handled properly.
|
||||
t.pass(&m.path_to_ui_test_for_metadata(
|
||||
"storage_map_no_keys",
|
||||
|
||||
Reference in New Issue
Block a user