Warning
This post was published 60 days ago. The information described in this article may have changed.
I've been trying to learn how to use rustdoc
and properly document my code. The rustdoc book
has been really helpful. However, I've hit a snag that I can't seem to resolve. Consider the following code snippet:
//! # Fake File For Frisking Rustdocs
//! Once upon a time there was a fish who aspired to become
//! a king.
/// ## The trick was to get the princess to kiss him.
pub mod princess {
pub fn princess_kiss() {
println!("The princess kissed the fish.");
}
pub fn princess_eat() {
println!("The princess ate the fish.");
}
pub fn the_moral() {
println!("If you want to become a king, you first have to risk being eaten by a fish.");
}
}
(Sorry about the silly story, but I needed some text.... :>) This code works just fine and rustdoc
creates some very nice documentation. However, when I add a use
statement to my code (and most Rust apps need use
statements) rustdoc generates an error. Here's the code with the use
statement added:
//! # Fake File For Frisking Rustdocs
//! Once upon a time there was a fish who aspired to become
//! a king.
/// ## The trick was to get the princess to kiss him.
pub mod princess {
use fltk;
pub fn princess_kiss() {
println!("The princess kissed the fish.");
}
pub fn princess_eat() {
println!("The princess ate the fish.");
}
pub fn the_moral() {
println!("If you want to become a king, you first have to risk being eaten by a fish.");
}
}
and here's the error:
error[E0432]: unresolved import `fltk`
--> src/lib.rs:8:9
|
8 | use fltk;
| ^^^^ no `fltk` in the root
I made sure that the Cargo.toml
file has FLTK declared in the dependency section. I imagine this has a simple fix, but I just can't find it. Any ideas?
3 posts - 2 participants
🏷️ rust_feed