mirror of
https://github.com/fluencelabs/marine-rs-sdk-test
synced 2024-12-04 23:30:18 +00:00
parsing mut types
This commit is contained in:
parent
0d28f77bdc
commit
f22fcbf95f
@ -37,7 +37,14 @@ impl ParseMacroInput for syn::ItemStruct {
|
||||
.iter()
|
||||
.map(|field| {
|
||||
check_field(field)?;
|
||||
let field_name = field.ident.as_ref().map(|ident| ident.to_string());
|
||||
let field_name = field.ident.as_ref().map(|ident| {
|
||||
ident
|
||||
.to_string()
|
||||
.split(' ')
|
||||
.last()
|
||||
.unwrap_or_default()
|
||||
.to_string()
|
||||
});
|
||||
let field_type = ParsedType::from_type(&field.ty)?;
|
||||
Ok(AstRecordField {
|
||||
name: field_name,
|
||||
|
@ -114,7 +114,7 @@ impl ParsedType {
|
||||
syn::Type::Path(path) => Ok(&path.path),
|
||||
_ => Err(Error::new(
|
||||
input_type.span(),
|
||||
"Incorrect argument type - only Vec<u8> and String are supported",
|
||||
"Incorrect argument type - passing only by value is supported now",
|
||||
)),
|
||||
}?;
|
||||
|
||||
@ -152,17 +152,9 @@ impl ParsedType {
|
||||
type_segment.span(),
|
||||
"type with lifetimes or generics aren't allowed".to_string(),
|
||||
)),
|
||||
_ => {
|
||||
let arg_name = (&type_segment.ident)
|
||||
.into_token_stream()
|
||||
.to_string()
|
||||
.split(' ')
|
||||
.last()
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
|
||||
Ok(ParsedType::Record(arg_name))
|
||||
}
|
||||
_ => Ok(ParsedType::Record(
|
||||
(&type_segment.ident).into_token_stream().to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user