Newbie question: example from documentation not working

I'm reading the Rust book at and have run into a problem in chapter 12. Specifically, the listing 12-9 doesn't work for me:
Refactoring to Improve Modularity and Error Handling - The Rust Programming Language

The errors i'm getting are:

no field query on type Result<Config, &str>
no field filename on type Result<Config, &str>

I was following along, making changes incrementally and then ran into this. I couldn't figure out where the differences were, and ended up just copying-and-pasting the entire listing just to get it to compile. But i still get the above errors.

Is there a mistake in the book? What should the listing be?

Listing 12-9 shows you only how the Config impl changes. At this point it's expected for the whole not to compile. The book then goes and shows how to adapt your main function to the new Config, in listing 12-10. At this point I think everything should compile again :slight_smile:

1 Like

Ugh, thank you, guess i should have read a bit further before bashing my head against this for a while! It's just that everywhere else in the book (so far) if an example won't compile it tells you so and explains why.

BTW, it's strange that this example is not marked as non-compilable by Ferris. I'm not sure how to fix it yet, but probably will have a look at it later today.


FYI - it took a little more then I expected, but here's the PR to add missing markers.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.