You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// for purposes of this example, this struct is defined in an external crate and cannot be modified.#[derive(Debug)]structPoint{x:i32,y:i32,}// therefore, this wrapper exists to add `FromStr` and `Display` implementations.#[derive(Debug, parse_display::FromStr, parse_display::Display)]#[display("<{0.x}, {0.y}>")]structPointWrapper(Point);
Expected Behavior
As all fields of the wrapped type are specified, no error occurs.
Observed Behavior
error: field `0` is not appear in format.
--> src/main.rs:8:11
|
8 | #[display("<{0.x}, {0.y}>")]
| ^^^^^^^^^^^^^^^^
The text was updated successfully, but these errors were encountered:
The ability to initialize a field with a constructor of its type does not exist, which is why this error is generated.
If a variable such as "{a.b}" is used in a format string, as in your example, I can implement the initialization ability using the constructor of the field type.
However, when using a variable such as "{a.b.c}" as shown in the following example, I cannot implement it because the macro cannot obtain the constructor name of the "a.b" part.
structPoint{x:i32,y:i32,}structKeyValue{key:i32,value:Point,}// The macro can't obtain the constructor name `Point`.#[derive(parse_display::FromStr)]#[display("key = {0.key}, value = <{0.value.x}, {0.value.y}>")]structWrapper(KeyValue);
For this reason, I have not implemented it until now, as it would be a strange "only available when the field nest is shallow" specification.
However, I think this specification is still useful, and if I can't think of a better one, I will try to implement it.
Example
Expected Behavior
As all fields of the wrapped type are specified, no error occurs.
Observed Behavior
The text was updated successfully, but these errors were encountered: