Use macros for creating the intermediate stage.
This is to make it easier to change function signatures by consolidating the places where the signatures exist.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::error::CustomError;
|
||||
|
||||
use super::macros::intermediate;
|
||||
use super::registry::Registry;
|
||||
use super::IPlainListItem;
|
||||
use crate::error::CustomError;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct IPlainList {
|
||||
@@ -9,22 +9,17 @@ pub(crate) struct IPlainList {
|
||||
pub(crate) children: Vec<IPlainListItem>,
|
||||
}
|
||||
|
||||
impl IPlainList {
|
||||
pub(crate) async fn new<'b, 'parse>(
|
||||
registry: &'b mut Registry<'parse>,
|
||||
original: &'b organic::types::PlainList<'parse>,
|
||||
) -> Result<IPlainList, CustomError> {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IPlainListItem::new(registry, obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
intermediate!(IPlainList, PlainList, |registry, original| async {
|
||||
let children = {
|
||||
let mut ret = Vec::new();
|
||||
for obj in original.children.iter() {
|
||||
ret.push(IPlainListItem::new(registry, obj).await?);
|
||||
}
|
||||
ret
|
||||
};
|
||||
|
||||
Ok(IPlainList {
|
||||
list_type: original.list_type,
|
||||
children,
|
||||
})
|
||||
}
|
||||
}
|
||||
Ok(IPlainList {
|
||||
list_type: original.list_type,
|
||||
children,
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user