Questions tagged [rust-obsolete]

Versions of Rust predating 1.0 can have drastically different syntax and semantics. Some questions for these versions no longer apply to a stable version of Rust but are of historical interest.

The Rust programming language evolved drastically before the first stable release. Code written for Rust 0.6 can have very different syntax from code written for Rust 1.0, and sometimes entire concepts or features of the language were added or removed.

This tag is for questions that are not applicable for any stable version of Rust (e.g. 1.0.0 and up).

50 questions
3
votes
1 answer

What is a modern analog to the deprecated std::raw::Repr?

I'm looking through some old (~2014) Rust code and I'm seeing this code block: fn compile(self, func:&UncompiledFunction<'a>) -> &'a Val { unsafe { use std::raw::Repr; use std::mem::transmute as cast; let slice =…
Matt
  • 3,508
  • 6
  • 38
  • 66
3
votes
1 answer

Unable to build Hyper - invalid character `-` in crate name

I am trying to run the hyper example listed on the Github readme. extern crate hyper; use std::io::Write; use hyper::Server; use hyper::server::Request; use hyper::server::Response; use hyper::net::Fresh; fn hello(_: Request, res:…
bipvanwinkle
  • 104
  • 1
  • 1
  • 6
3
votes
1 answer

Collect into owned vec of owned strings in rust

I am trying to collect into an vec of strings in rust using the following: let fields : ~[~str] = row.split_str(",").collect(); I get the following error: expected std::iter::FromIterator<&str>, but found std::iter::FromIterator<~str> (str storage…
rdmcfee
  • 540
  • 6
  • 13
3
votes
2 answers

Getting basic input for ints

I'm quite surprised I can't seem to navigate rust's documentation to find any case that describes io, could someone please explain to me how to use basic io to get user input into say, an integer? And maybe where to find the io details in that…
Syntactic Fructose
  • 18,936
  • 23
  • 91
  • 177
3
votes
1 answer

Return a closure from a function

Note that this question pertains to a version of Rust before 1.0 was released Do I understand correctly that it is now impossible to return a closure from a function, unless it was provided to the function in its arguments? It is very useful…
Vladimir Matveev
  • 120,085
  • 34
  • 287
  • 296
3
votes
1 answer

Comparing string with static string

Here's an example of what I've tried. static TARGET: &'static str = "a string"; fn main () { printfln!("%?", TARGET.eq(~"other string")); } I looked at equiv too, but no luck. The string I compare to the TARGET has to be an owned pointer string.
Johanna Larsson
  • 10,531
  • 6
  • 39
  • 50
3
votes
1 answer

How to make Rust compiler resolve import from std?

I'm using the Rust 0.6 compiler for mingw32. I'm able to compile small programs that import from "core", but not from "std". Here is a transcript showing a trivial example and how I am compiling it: $ cat prog.rs use std; $ rustc.exe…
Arch D. Robison
  • 3,829
  • 2
  • 16
  • 26
2
votes
1 answer

How to get square root in Rust 0.13.0?

In 0.13.0-nightly the following code won't compile: fn main() { let a = (10.5f64).sqrt(); } I get the error: error: type `f64` does not implement any method in scope named `sqrt` What am I doing wrong?
RajV
  • 6,860
  • 8
  • 44
  • 62
2
votes
1 answer

Rust won't narrow down types? Or did I make a mistake

Trying to write something similar to Haskell's HList, with the ability to search by type. With the below code, in play.rust-lang.org version rustc 0.13.0-dev (567b90ff0 2014-12-13 20:02:15 +0000) I get an error: :35:26: 35:31 error: unable to…
Sgeo
  • 85
  • 8
2
votes
2 answers

How would you stream output from a Process in Rust?

This question refers to Rust as of October 2014. If you are using Rust 1.0 or above, you best look elsewhere for a solution. I have a long running Rust process that generates log values, which I'm running using Process. It looks at though I might…
Doug
  • 32,844
  • 38
  • 166
  • 222
2
votes
1 answer

difficulty with rust binary tree implementation

I am trying to implement a simple binary search tree in Rust but I am having difficulty pinning down an issue with inserting nodes. I am using the following data structures and functions. enum BinaryTree { Leaf(T), Branch(T,…
DarthShoge
  • 23
  • 1
  • 3
2
votes
1 answer

Conditional compilation in Rust 0.10?

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…
Sean Perry
  • 3,776
  • 1
  • 19
  • 31
2
votes
1 answer

Rust "error: moving out of immutable field"

I've created the following Rust struct: struct HTTPRequestHeader { name: ~str, data: ~str, next: Option<~HTTPRequestHeader> } And the following code to print it: fn print_headers(hdr: &HTTPRequestHeader) { println(fmt!("%s: %s",…
limp_chimp
  • 13,475
  • 17
  • 66
  • 105
2
votes
1 answer

Difference between &T and T/&, ~T and T/~

What is the difference between having the pointer type prefixing the type versus having it postfix with a slash prior to it. What does the slash even mean?
Havvy
  • 1,471
  • 14
  • 27
1
vote
1 answer

Type information of a proc() cannot be inferred if not passed into spawn()

This compiles: use std::num::pow; pub fn main() { let (tx, rx): (Sender, Receiver) = channel(); let square_tx = tx.clone(); let square = proc() { let mut x = 1u; loop { square_tx.send(pow(2u64,…
Jin
  • 12,748
  • 3
  • 36
  • 41