-
Notifications
You must be signed in to change notification settings - Fork 1
Added StaticDataSize
trait and derive macros for DataSize
and StaticDataSize
#1
Conversation
and implemented it for some useful types
+ Added some tests and fixes
Types like Option<T> can now use this derive macro correctly
+ Added DataSize and StaticDataSize for some more types
It is no needed because we can just use <WraperType<T>>::func()
+ reformatted and removed useless statements
+ Added infos in `datasize_macro`'s `Cargo.toml`
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.
This is good! There are some things that I think need to be changed (see comments), and some that could be changed but mostly just for readability :)
I didn't know about the |
Yes that is really useful for this right now. |
By the way, just a terminology thing: lifetimes are generics. In the same way that generic types represent a non-specific type with certain bounds (such as the places that generic type is put), lifetimes are generic in that they don't represent a specific length of time, rather just a non-specific length of time, where you may annotate that certain things live for at least the same lifetime as others by placing lifetimes in those positions. So 'generics' refers to both generic types and lifetimes :) |
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.
Not done reviewing, will finish probably tomorrow. Looks good! Maybe one or two minor things I guess, too tired to read properly now :p
.collect(); | ||
|
||
quote! { | ||
Self::#ident {#(#names),*} => { 0usize #( + #names.data_size())*}, |
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 realize this should be 1usize
right? To include the discriminant?
It is now possible to implement
StaticDataSize
andDataSize
traits with derive macro !The only thing left to do is the documentation :)