1

我正在学习 Rust,昨天在http://reddit.com/r/rust上看到了关于Nickel的帖子。作为空闲时间的 Node.js 开发人员,我有兴趣检查一下。

我从http://rust-lang.org下载了 Rust 1.0.0-beta DMG 。

我完全按照Hello World教程进行操作,当我cargo run在终端中执行时,我收到以下错误:

Robs-MacBook-Pro:nickel-demo rob$ cargo run
   Compiling nickel-demo v0.0.1 (file:///Users/rob/Workbench/nickel-demo)
src/main.rs:4:1: 4:21 error: an external crate named `nickel` has already been imported into this module [E0259]
src/main.rs:4 extern crate nickel;
              ^~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `nickel-demo`.

Nickel 演示的 Hello Worldmain.rs文件如下所示:

extern crate nickel;

#[macro_use] extern crate nickel_macros;
extern crate nickel;

use nickel::Nickel;

fn main() {
    let mut server = Nickel::new();

    server.utilize(router! {
        get "**" => |_req, _res| {
            "Hello world!"
        }
    });

    server.listen("127.0.0.1:6767");
}

当我在编辑器中输入这段代码时,我特别认为我extern crate nickel;在文件中声明了两次很奇怪。收到错误后,我将代码重构为:

extern crate nickel;

#[macro_use] extern crate nickel_macros;

use nickel::Nickel;

...

我得到这个错误:

Robs-MacBook-Pro:nickel-demo rob$ cargo run
   Compiling nickel-demo v0.0.1 (file:///Users/rob/Workbench/nickel-demo)
     Running `target/debug/nickel-demo`
Listening on http://127.0.0.1:6767
Ctrl-C to shutdown server
thread '<main>' panicked at 'arithmetic operation overflowed', /Users/rob/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.3.11/src/server/mod.rs:90
An unknown error occurred
4

1 回答 1

4

arithmetic operation overflowed错误似乎是上游问题。它还会影响镍所依赖的超。

https://github.com/seanmonstar/num_cpus/issues/2

作为一种临时解决方法,用于cargo build --release完全阻止检查。

于 2015-04-13T13:49:04.100 回答