当我运行时cargo build,各种库存储在文件夹中/usr/local/lib/rustlib/.
清除这些库的正确方法是什么?我可以rm手动这些文件,但这是正确的做法吗?我注意到这/usr/local/lib/rustlib/manifest是一个包含所有库的填充文件路径列表的文件,因此如果我手动删除这些文件可能会破坏某些内容.
运行时cargo build:
error: multiple matching crates for `url`
Run Code Online (Sandbox Code Playgroud)
然后列出候选人:
./target/deps/liburl-11a95471847b9e04.rlib/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liburl-4e7c5e5c.{so,rlib}......然后中止,因为它无法决定哪一个.
src/http/lib.rs:18:1: 18:18 error: can't find crate for `url`
src/http/lib.rs:18 extern crate url;
^~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题,或解决这个问题?
注意:
+//! rust-url’s crate is also named `url`.
+//! Cargo will automatically resolve the name conflict,
+//! but that means that you can not also use the old `url` in the same crate.
Run Code Online (Sandbox Code Playgroud)
安装细节:
$ rustc -v
rustc 0.12.0-pre-nightly (7a25cf3f3 …Run Code Online (Sandbox Code Playgroud) 我得到一个生锈编译错误:
src/main.rs:33:31: 33:35 error: can't capture dynamic environment in a fn item; use the || { ... } closure form instead
Run Code Online (Sandbox Code Playgroud)
发生错误是因为我有一个函数,我在其中声明一个变量使用let,然后有一个内部函数,我尝试使用这个被关闭的变量.
我相当肯定这是一个初学者的问题,如果这有一个非常直截了当的答案,请提前抱歉!
请注意,我正在使用此内部函数作为回调,因此使用闭包,如
let closure_fn = | args | -> () { do stuff };
Run Code Online (Sandbox Code Playgroud)
......对我来说不是一个合适的解决方案.
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn stub_3rd_party_function() -> String {
"hello world".to_string()
}
fn main() {
let mut server = Nickel::new();
// assume that the variable **must** be instantiated like this
let hello_text : String …Run Code Online (Sandbox Code Playgroud)