pixel
March 10, 2016, 8:09pm
1
So using this for lib.rs:
extern crate iron;
use iron::Request;
/// ```
/// use iron::Request;
///
/// fn handle(req : &mut Request) {
/// }
///```
pub fn handle(req : &mut Request) {
}
When i run "cargo test" I get:
<anon>:2:10: 2:14 error: unresolved import `iron::Request`. Maybe a missing `extern crate iron`? [E0432]
<anon>:2 use iron::Request;
^~~~
If I update the code to:
extern crate iron;
use iron::Request;
/// ```
/// extern crate iron;
/// use iron::Request;
///
/// fn handle(req : &mut Request) {
/// }
///```
pub fn handle(req : &mut Request) {
}
"cargo test" gives me:
<anon>:3:10: 3:14 error: unresolved import `iron::Request`. Did you mean `self::iron`? [E0432]
<anon>:3 use iron::Request;
^~~~
So obviously I'm missing something, but I can't figure out what.
gkoz
March 10, 2016, 9:04pm
2
Is iron
listed in dev-dependencies
?
pixel
March 10, 2016, 9:13pm
3
It wasn't. I added it but that didn't seem to make a difference. My Cargo.toml now is:
[package]
name = "test"
version = "0.0.1"
[dependencies]
iron = "*"
[dev-dependencies]
iron = "*"
Seemed like a reasonable idea, but I still get the same error as before if I include the extern crate or not.
bluss
March 10, 2016, 9:29pm
4
You don't need to list it twice. The example needs to do the extern crate iron;
thing itself.
pixel
March 10, 2016, 9:33pm
5
Uhm that's when I get:
---- handle_0 stdout ----
<anon>:2:10: 2:14 error: unresolved import `iron::Request`. Maybe a missing `extern crate iron`? [E0432]
<anon>:2 use iron::Request;
^~~~
error: aborting due to previous error
thread 'handle_0' panicked at 'Box<Any>', ../src/libsyntax/errors/mod.rs:527
as an error for the code:
extern crate iron;
use iron::Request;
/// ```
/// use iron::Request;
///
/// fn handle(req : &mut Request) {
/// }
///```
pub fn handle(req : &mut Request) {
}
Or did I misunderstand what you were saying?
pixel
March 11, 2016, 1:02am
6
Well it looks like I figured it out, it's the function that is screwing things up. If I do:
/// ```
/// # extern crate iron;
/// use iron::Request;
/// # fn main() {
/// fn handle(req : &mut Request) {
/// }
/// # }
///```
It tests fine and produces documentation that is mostly fine. This produces:
use iron::Request;
fn handle(req : &mut Request) {
}
Apparently I can't add a blank line after "use iron:Request" or the HTML only includes the first line, likewise if I add a blank line inside the function, everything after the blank line is removed.....seems odd, but I can move forward.