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.