-
Notifications
You must be signed in to change notification settings - Fork 52
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
Close #109: Add crate_module_path
#111
Conversation
@awesomelemonade Before I merge, please check if this works for your usecase. |
I'm not @awesomelemonade but am maintainer of the Leptos framework that prompted the discussion, and yes, this should work perfectly, as it would allow us to specify the re-exported path to as Thanks for all your work on this great library. |
It looks like there's an additional direct For example, the following #[derive(::leptos::typed_builder_macro::TypedBuilder)]
#[builder(crate_module_path = typed_builder)]
struct InfoGridProps<const NUM_ROWS: usize, const NUM_COLS: usize> {
data: [[u32; NUM_ROWS]; NUM_COLS],
#[builder(default)]
optional_prop: bool,
} expands to code including the following #[allow(dead_code, non_camel_case_types, missing_docs)]
impl<
const NUM_ROWS: usize,
const NUM_COLS: usize,
// ❌ crate_module_path not used here
__optional_prop: ::typed_builder::Optional<bool>,
> InfoGridPropsBuilder<
NUM_ROWS,
NUM_COLS,
(([[u32; NUM_ROWS]; NUM_COLS],), __optional_prop),
> {
#[allow(clippy::default_trait_access)]
pub fn build(self) -> InfoGridProps<NUM_ROWS, NUM_COLS> {
let (data, optional_prop) = self.fields;
let data = data.0;
// crate_module_path is used here
let optional_prop = ::leptos::typed_builder::Optional::into_value(
optional_prop,
|| ::core::default::Default::default(),
);
#[allow(deprecated)]
InfoGridProps {
data,
optional_prop,
}
.into()
}
} |
Yes, this is the problem: rust-typed-builder/typed-builder-macro/src/struct_info.rs Lines 404 to 428 in 628786a
I think I missed it because, for performance reasons, it's not written as Not 100% sure if I should change it to a |
@gbj I pushed a fix. Please try again. |
It works! Thank you so much! |
e15bd2e
to
3f78ca5
Compare
No description provided.