-
Notifications
You must be signed in to change notification settings - Fork 101
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
derive: Support #[row(crate = ...)]
#189
base: main
Are you sure you want to change the base?
derive: Support #[row(crate = ...)]
#189
Conversation
#[row(crate = ...)]
Co-authored-by: Philip Dubé <serprex@users.noreply.github.com>
@@ -0,0 +1,2 @@ | |||
mod row; | |||
pub use row::Row; |
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.
pub(crate)
(and all below). It seems this subcrate doesn't use https://github.com/ClickHouse/clickhouse-rs/blob/main/Cargo.toml#L17
@@ -35,12 +55,14 @@ fn column_names(data: &DataStruct, cx: &Ctxt, container: &Container) -> TokenStr | |||
|
|||
// TODO: support wrappers `Wrapper(Inner)` and `Wrapper<T>(T)`. | |||
// TODO: support the `nested` attribute. | |||
// TODO: support the `crate` attribute. | |||
#[proc_macro_derive(Row)] | |||
#[proc_macro_derive(Row, attributes(row))] | |||
pub fn row(input: proc_macro::TokenStream) -> proc_macro::TokenStream { |
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 patch deserves a docstring
type Error = &'a syn::Attribute; | ||
|
||
fn try_from(attr: &'a syn::Attribute) -> Result<Self, Self::Error> { | ||
if attr.path().is_ident(ATTRIBUTE_NAME) { |
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 very important (because it's a private API), but it's more straightforward to return an error (even a simple string) and panic in the From
instance.
|
||
impl From<&[syn::Attribute]> for Attributes { | ||
fn from(attrs: &[syn::Attribute]) -> Self { | ||
let mut row = None; |
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.
What is point to use None
here instead of Row::default()
?
Summary
derive
crate.#[row(crate = ...)]
attribute