How to use the crate derive_builder with a struct implemented in a module?

Hi all,

I have trouble to use the crate derive_builder with structs which are not defined in I'm using the last version of derive_builder (0.8.0).

Here's a minimal example :

// ./src/
extern crate derive_builder;

mod data_structure;
use data_structure::Foo;

fn main() {
// ./src/
use derive_builder::Builder;

#[derive(Default, Clone, Builder)]
pub struct Foo {
    pub bar: String,

This example give me the following error :

error[E0599]: no method named `bar` found for type `data_structure::Foo` in the current scope
 --> src/
8 |     Foo::default().bar("test");
  |                    ^^^-------- help: remove the arguments
  |                    |
  |                    field, not a method
 ::: src/
6 | pub struct Foo {
  | -------------- method `bar` not found for this

I've tried this example without success with the last stable version of rust (1.38.0) and the nightly version of rust (1.40.0-nightly).

I'm missing something ?


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.