6 ms·
Regarding compile time, you can track the passes with `-Z time-passes` and wait for borrowck/lints to get over (or just typeck if you're only worried about type
by Manishearth 11y ago
Regarding compile time, you can track the passes with `-Z time-passes` and wait for borrowck/lints to get over (or just typeck if you're only worried about types).
There also was [this plugin](http://www.reddit.com/r/rust/comments/2krdbu/rest_easy_a_lint_to_tell_you_when_compilation/ http://www.reddit.com/r/rust/comments/2krdbu/rest_easy_a_lin...), but it's outdated at the moment (I can upgrade it later).
Regarding imports, `use foo::bar::*` works.
- viraptor 11y agoFor use, I meant that there are so many packages you just take space just listing them. For basic iron you need: iron::prelude::*, iron::status, staticfile, logger, router, handlebars_iron, and more. And these are all from different crates.
- Jweb_Guru 11y agoThis is the same in even many dynamic languages, though, isn't it?
- viraptor 11y agoAlmost. In Rust to use a trait, you have to explicitly import it. That means if you want to run `.to_json()` on something, you need to import trait `ToJson`. Then again if you want to force a type of something (for example an empty hashmap) you need to import the types which are included. So what in a dynamic language could be: a.to_json() if a else {}.to_json() In rust will start with: use rustc_serialize::json::{ToJson,Json}; use std::collections::BTreeMap; ...
- filsmick 11y agoI'd love something similar to be part of Cargo, maybe as an option in the manifest. Like the author, I've learned to guess when the codegen starts, but having this information displayed would be useful.
- kibwen 11y agoI'm actually working right now on a `cargo check` command which only runs those phases of the compiler to do with typechecking, to accommodate workflows based around tweaking types and then running the compiler to check your work. Given that the vast majority of compilation time is currently based in code generation and linking, this should drastically improve usability for this sort of rapid-iteration, dynamic-language-style workflow. (Though also note that improving the speed of codegen and linking is an ongoing task as well.)
- mafribe 11y agoThis is a great idea. I wish other compilers would offer this feature (scalac is in dire need of such an option). Does the Rust macro system require compile-time compilation before type-checking?
- Jweb_Guru 11y agoNot really. Macro expansion occurs during its own phase of compilation (which, in my experience, is generally really fast).
- mafribe 11y agoMacro expansion can lead to programs that don't typecheck, unless a very restrictive typing system is used (e.g. MetaML, MetaOcaml). I don't think Rust has such restrictions, therefore I assume that type-checking happens after macro expansion.
- Jweb_Guru 11y agoIt does, but what I was getting at was that full compilation doesn't need to occur first. Macro expansion is one of the very first phases of compilation (and doesn't have access to typechecking information, incidentally).
- 11y ago