REASY opened a new issue, #2866:
URL: https://github.com/apache/fory/issues/2866
### Feature Request
The code below does not compile
```Rust
macro_rules! impl_value {
($record:ident, $value:ident, { $($field:ident : $ty:ty = $expr:expr),*
$(,)? }) => {
#[derive(ForyObject)]
pub struct $value {
$(pub $field: $ty,)*
}
impl $record {
pub fn to_key_value(self) -> (String, $value) {
let Self {
feature_key,
$($field,)*
} = self;
let value = $value {
$($field: $expr,)*
};
(feature_key, value)
}
}
};
}
#[derive(Debug, Clone)]
pub struct KeyValue {
feature_key: String,
count: u64,
last_seen_event_time: DateTime<Utc>,
}
impl_value!(
KeyValue,
Value,
{
count: u64 = count,
last_seen_event_time: NaiveDateTime =
last_seen_event_time.naive_utc(),
}
);
#[test]
fn test_in_macro() {
let key_value = KeyValue {
feature_key: "test_key".to_string(),
count: 100,
last_seen_event_time: Utc::now(),
};
let (key, value) = key_value.clone().to_key_value();
assert_eq!(key, "test_key");
assert_eq!(value.count, 100);
assert_eq!(value.last_seen_event_time,
key_value.last_seen_event_time.naive_utc());
}
```
With slight modification of
[rust/fory-derive/src/object/read.rs](rust/fory-derive/src/object/read.rs)
compiler shows
```
error: proc-macro derive panicked
--> tests/tests/test_fory.rs:203:18
|
203 | #[derive(ForyObject)]
| ^^^^^^^^^^
...
232 | / impl_value!(
233 | | KeyValue,
234 | | Value,
... |
239 | | );
| |_- in this macro invocation
|
= help: message: Unsupported type: Type::Group { group_token: Group,
elem: Type::Path { qself: None, path: Path { leading_colon: None, segments:
[PathSegment { ident: Ident { ident: "u64", span: #0 bytes(7225..7228) },
arguments: PathArguments::None }] } } }
= note: this error originates in the macro `impl_value` (in Nightly
builds, run with -Z macro-backtrace for more info)
```
### Is your feature request related to a problem? Please describe
_No response_
### Describe the solution you'd like
_No response_
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]