2

I have been using 0.10 and recently setup a build of nightly to experiment with Box and friends.

Now I have code for 0.10 using ~str and code for pre0.11 using String because of to_owned being obsolete. I thought I could do this:

#[cfg(rust_version = "0.10")]
fn my_old_func() -> Option<~str> {
}

#[cfg(not(rust_version = "0.10")]
fn my_old_func() -> Option<String> {
}

And pass --cfg rust_version:0.11 during compilation. But the compiler still chokes on the now removed ~ operator. Is there a way to have code that works under both 0.10 and the as yet unreleased 0.11 using conditional compilation or some other mechanism?

I guess I could fall back to using cpp and #ifdef but that seems like stepping out of the Rust mindset.

4

1 回答 1

3

不,您对此无能为力。

我们的典型建议不是使用 0.10,而是坚持使用 nightlies。

于 2014-06-19T01:00:07.727 回答