`test` crate, `Bencher`

What's this test crate? What's test::Bencher?

I can't find any documentation, so I guess it was dropped. I've found so code using it so it would be nice to know whether there are any replacements.

Test is a library shipped by the compiler that is used to implement the rustc --test and rustc --bench compiler features.

The library itself is unstable and hidden behind the #[feature(test)] flag.

To my knowledge, the only available docs care here: https://github.com/rust-lang/rust/tree/master/src/libtest

You can also read a bit about it in The Book

Thanks guys. I saw the stuff in the book and assumed it was old; guess not.

I was seriously hoping I could just use Rust on the stable builds by now...

So I spent a while banging my head against the compiler earlier trying to work out why it claimed std::io didn't exist. Then I realised: it doesn't in the stable releases. So much for calling them releases (they're unusable unless you're expected to implement your own IO libraries or some such).

What? Are you, perhaps, trying to call a function or use a type from it in a module, without usein std?

mod foo {
    //Will not work
    struct Foo(std::io::Error);
}
mod foo {
    //Will work. Note the :: at the beginning
    struct Foo(::std::io::Error);
}

mod bar {
    use std;
    //Will also work, now when `std` is
    //imported into the local namespace
    struct Bar(std::io::Error);
}

Really? Sorry, I feel stupid for jumping to conclusions like that. But error messages like this should surely hint about that!

src/detail/mod.rs:16:26: 16:30 error: use of undeclared type name Read [E0412]
src/detail/mod.rs:16 fn read_head(r: &mut Read) -> Result {
^~~~

You didn't import Read, and it's not part of the std::prelude imported automatically, so how do you expect the compiler to know what you meant?

It is part of std::io::prelude though, so you can use that to get all the io basics in one shot.

Wow.

Please try to be more constructive in the future.

Yeah, I wasn't having a good day. Sorry about that.

Because this was in my file:

use std::io::{Read, Result};

Just not the same module. I guess I have to unlearn what I had assumed about imports from C, Java, Python, Bash, Scala and just about anything else I can think of. Even C++'s using namespace XYZ; come to think of it. #shrug#

Not Python, at least. Imports work almost exactly like Python's. The difference is that you can't have more than one module per file there.

Well, the good part is that it won't clutter your namespace with things you don't need in the submodules :smile:

Yeah. I'm fine with everything other than the error messages not pointing this out.

Well, assuming you mean the message you posted earlier about Read, what would you like the compiler to say? It can't know you are referring to std::io::Read. And looking into imports in other modules to figure out what this module wants to import is probably not a good enough guess for compiler suggestions.

birkenfeld: it would be enough if the compiler noticed it was working within a sub-module in the file and pointed out that use statements apply to (sub)-modules not files, I think.