Skip to content

Commit

Permalink
Merge pull request #33 from DLR-FT/dadada/fix-check-on-alt-name
Browse files Browse the repository at this point in the history
Fix use of struct ident as alt name
wucke13 authored Jan 10, 2024
2 parents 8894ae5 + b09c064 commit 695f824
Showing 1 changed file with 28 additions and 33 deletions.
61 changes: 28 additions & 33 deletions macros/src/parse/channel.rs
Original file line number Diff line number Diff line change
@@ -191,46 +191,41 @@ impl Channel {
Item::Struct(mut item) => {
let mut vec: Vec<Option<darling::Result<Channel>>> = vec![
SamplingOutProc::may_from_attributes(&mut item.attrs).map(|x| {
let alt_name: ApexName =
FromMeta::from_string(&item.ident.to_string())?;

x.map(|mut x| {
if x.name.0.is_empty() {
x.name = alt_name;
}
Channel::SamplingOut(item.ident.clone(), x)
})
let mut x = x?;
if x.name.0.is_empty() {
let alt_name: ApexName =
FromMeta::from_string(&item.ident.to_string())?;
x.name = alt_name;
}
darling::Result::Ok(Channel::SamplingOut(item.ident.clone(), x))
}),
SamplingInProc::may_from_attributes(&mut item.attrs).map(|x| {
let alt_name: ApexName =
FromMeta::from_string(&item.ident.to_string())?;
let mut x = x?;
if x.name.0.is_empty() {
let alt_name: ApexName =
FromMeta::from_string(&item.ident.to_string())?;

x.map(|mut x| {
if x.name.0.is_empty() {
x.name = alt_name;
}
Channel::SamplingIn(item.ident.clone(), x)
})
x.name = alt_name;
}
darling::Result::Ok(Channel::SamplingIn(item.ident.clone(), x))
}),
QueuingOutProc::may_from_attributes(&mut item.attrs).map(|x| {
let alt_name: ApexName =
FromMeta::from_string(&item.ident.to_string())?;
x.map(|mut x| {
if x.name.0.is_empty() {
x.name = alt_name;
}
Channel::QueuingOut(item.ident.clone(), x)
})
let mut x = x?;
if x.name.0.is_empty() {
let alt_name: ApexName =
FromMeta::from_string(&item.ident.to_string())?;
x.name = alt_name;
}
darling::Result::Ok(Channel::QueuingOut(item.ident.clone(), x))
}),
QueuingInProc::may_from_attributes(&mut item.attrs).map(|x| {
let alt_name: ApexName =
FromMeta::from_string(&item.ident.to_string())?;
x.map(|mut x| {
if x.name.0.is_empty() {
x.name = alt_name;
}
Channel::QueuingIn(item.ident.clone(), x)
})
let mut x = x?;
if x.name.0.is_empty() {
let alt_name: ApexName =
FromMeta::from_string(&item.ident.to_string())?;
x.name = alt_name;
}
darling::Result::Ok(Channel::QueuingIn(item.ident.clone(), x))
}),
];
let vec: Vec<_> = vec

0 comments on commit 695f824

Please sign in to comment.