error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
The error message is pointing you to the solution. You might be used to error messages not being helpful, but in Rust they usually point you in the right direction.
That being said, you need to use the nightly channel of compiler, so all you need to do is this (assuming you're using rustup and you have installed the nightly channel):
rustup override set nightly
If you haven't installed the nightly release channel, you'll have to do this before running the command above:
I don't think so, this one looks to me like it will be stabilised eventually. But stabilisation takes time, effort and feedback from the users, all being scarce sometimes in open source.
If you put the large examples in examples/[1], Cargo will automatically treat them as example targets. You can run them as tests with cargo test --examples or cargo test --all-targets.
You can manually import them with include_str!, e.g.:
Perhaps include-utils is only intended to work with markdown files ?
I created a hello_world project using
cargo new hello_world
I then changed the Cargo.toml dependencies to
[dependencies]
include-utils = "0.2.4"
and changed main.rs to
use include_utils;
/// Hello World
/// '''
#[doc = include_utils::include_md!("src/main.rs:main")]
/// '''
///
// ANCHOR: main
fn main() {
println!("Hello, world!");
}
// ANCHOR_END: main
~
I then ran cargo doc and got the following error:
hello_world>cargo doc
Documenting hello_world v0.1.0 (/Users/bradbell/trash/rust/hello_world)
error: Included file doesn't contain anchor with name: main
--> src/main.rs:5:9
|
5 | #[doc = include_utils::include_md!("src/main.rs:main")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `include_utils::include_md` (in Nightly builds, run with -Z macro-backtrace for more info)
error: could not document `hello_world`
Looks like anchors are not supported for include_str_part!. Raising an issue in the repo might be a good idea, I don't see a reason why this shouldn't be supported. A suitable regex can be found in the mdbook docs:
The line beginning an anchor must match the regex ANCHOR:\s*[\w_-]+ and similarly the ending line must match the regex ANCHOR_END:\s*[\w_-]+. This allows you to put anchors in any kind of commented line.