Questions tagged [rust-0.8]

Rust is a native system programming language; its most notable use is the research layout engine Servo. Use this tag for specific issues for version 0.8

7 questions
18
votes
1 answer

How can I read and write a text file in Rust?

Note: this question is about pre Rust 1.0 and thus outdated. See the linked duplicate for an up to date answer. I'm writing a test program using Rust 0.8 on Win8, and I need to read and write some parameters used by the program to/from a text…
Brian Oh
  • 9,604
  • 12
  • 49
  • 68
11
votes
3 answers

How do I return an owned array from a function?

I'm a Rust newbie trying to figure out the language by playing with it. I've hit some problems on trying to return an array from a function: struct Widget { thingies: ~[int] } impl Widget { fn new() -> Widget { Widget { thingies: ~[4,…
Greg Malcolm
  • 3,238
  • 4
  • 23
  • 24
8
votes
4 answers

Can this Rust code be written without the "match" statement?

linuxfood has created bindings for sqlite3, for which I am thankful. I'm just starting to learn Rust (0.8), and I'm trying to understand exactly what this bit of code is doing: extern mod sqlite; fn db() { let database = match…
Brian Oh
  • 9,604
  • 12
  • 49
  • 68
7
votes
1 answer

Why using Rust does passing a mutable struct to a function result in immutable fields?

I'm learning Rust using 0.8 on Win8-64. I have a test program I'm working on where a function that handles input of parameters returned a struct containing those parameters. That worked OK. I then altered the program to pass the &struct to the…
Brian Oh
  • 9,604
  • 12
  • 49
  • 68
4
votes
1 answer

Calling an on-heap function argument inside of a closure

I'm using rust 0.8. Why is it that I can do this: fn add(num: ~int) -> ~fn(int) -> int { |x| *num + x } but not this: fn outer(num: ~int) -> ~fn(int) -> int { |x| *inner(num) + x } fn inner(num: ~int) -> ~int { num } the second one…
nnythm
  • 3,280
  • 4
  • 26
  • 36
2
votes
2 answers

How do I convert a Zip into an array in rust 0.8?

The docs seem to indicate that after zipping two iterators together, you can turn them into an array with .from_iterator(), but when I try to do this, rust reports: std::iter::Zip,std::vec::VecIterator<,int>>` does not…
mcandre
  • 22,868
  • 20
  • 88
  • 147
2
votes
1 answer

How can I detect an error rather than have this Rust program abort?

When running the following test program (below) using Rust 0.8 on win8, if I run two instances of the program simultaneously, when the first program is waiting for input (line 12), then the second program aborts (line 7) with fatal error message…
Brian Oh
  • 9,604
  • 12
  • 49
  • 68