turns out that one *can* use 'extern crate' in submodules
[rust-101.git] / src / part13.rs
index 811411cc25c27113588cec5c5624bba17ae7394c..29647ea60a3504e4d86a8fa562e864f26435940f 100644 (file)
@@ -87,13 +87,13 @@ fn sort_array() {
 //@ Note that crates.io is only the default location for dependencies, you can also give it the URL of a git repository or some local
 //@ path. All of this is explained in the [Cargo Guide](http://doc.crates.io/guide.html).
 
-// I disabled the following module (using a rather bad hack), because it only compiles if `docopt` is linked. However, before enabling it,
-// you still have get the external library into the global namespace. This is done with `extern crate docopt`, and that statement *has* to be
-// in `main.rs`. So please go there, and enable this commented-out line. Then remove the attribute of the `rgrep` module.
+// I disabled the following module (using a rather bad hack), because it only compiles if `docopt` is linked.
+// Remove the attribute of the `rgrep` module to enable compilation.
 #[cfg(feature = "disabled")]
 pub mod rgrep {
-    // Now that `docopt` is linked and declared in `main.rs`, we can import it with `use`. We also import some other pieces that we will need.
-    use docopt::Docopt;
+    // Now that `docopt` is linked, we can first root it in the namespace and then import it with `use`. We also import some other pieces that we will need.
+    extern crate docopt;
+    use self::docopt::Docopt;
     use part12::{run, Options, OutputMode};
     use std::process;
 
@@ -149,7 +149,7 @@ Options:
     // Finally, we can call the `run` function from the previous part on the options extracted using `get_options`. Edit `main.rs` to call this function.
     // You can now use `cargo run -- <pattern> <files>` to call your program, and see the argument parser and the threads we wrote previously in action!
     pub fn main() {
-        run(get_options());
+        run(get_options());                                         /*@*/
     }
 }
 
@@ -158,4 +158,4 @@ Options:
 // the pattern to regular-expression mode, and change `filter_lines` to honor this option. The documentation of regex is available from its crates.io site.
 // (You won't be able to use the `regex!` macro if you are on the stable or beta channel of Rust. But it wouldn't help for our use-case anyway.)
 
-//@ [index](main.html) | [previous](part12.html) | [next](main.html)
+//@ [index](main.html) | [previous](part12.html) | [next](part14.html)