-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tabled attribute format #398
Conversation
315142c
to
c94aa8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised that you got this fight 😄
So overall pretty decent 👍 .
I'd have some comments according to style.
But I have them against my own code, and the current state of tabled_derive
in particular.... 😥
Let me know what you think and whether,
you will be able to address my comments.
Take care
tabled/tests/derive/derive_test.rs
Outdated
expected: ["0", "1"], ["0", "foo v2"], | ||
); | ||
|
||
// todo : self is the tuple here. It should be the sstr element instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good call to test self
but what's the issue, exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a tuple and this is what self is representing here, instead it should represent the sstr property of the tuple.
I can't call this property as it's not a struct. Do you see what I mean ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow I do believe that self
must be a tuple?
no?
And yes, don't worry about merge conflicts. |
Am I wrong that with your changes And I bet it's good. Just need to document and create tests. |
You are right! I added one test, let me know if it's fine. |
…tabled-attribute-format
Hey @thomassimmer I'll merge it, But could you let me know your thoughts on this #[test]
fn format3() {
#[derive(Debug, Tabled)]
struct StructName(u8, #[tabled(format("foo {} {:?}", 2, self))] String);
let value = StructName(0, String::from("string"));
assert_eq!(value.fields(), vec!["0", "foo 2 StructName(0, \"string\")"]);
assert_eq!(StructName::headers(), vec!["0", "1"]);
} Thanks for contribution. |
Hi @zhiburt , What you said on tuples sounds good to me too! Thank you for merging and take care. |
Hello,
This is for #396 .
I hope it's fine, it was probably a bit too difficult for me as a first issue. I tried to do something very similar to display_with but I encounter some difficulties with properties and nested structs/enums. I would be happy to see what corrections you can make to improve it.
By the way, thanks a lot for the library! :)
FYI, I needed that for this project : https://github.com/thomassimmer/NeoPass
Cheers