Rust is a native system programming language; its most notable use is the research layout engine Servo. Use this tag for issues only known for version 0.9
Questions tagged [rust-0.9]
7 questions
52
votes
3 answers
What is the simplest way to convert a string to upper case in Rust?
I've been looking into how you convert a string to upper case in Rust. The most optimal way I've figured out so far is this:
let s = "smash";
let asc = s.to_ascii().to_upper();
println!("Hulk {:s}", asc.as_str_ascii());
Is there a less verbose way…

Greg Malcolm
- 3,238
- 4
- 23
- 24
10
votes
1 answer
Clone a struct storing a closure
I'm currently trying to implement a simple Parser-Combinator library in Rust. For that I would like to have a generic map function to transform the result of a parser.
The problem is that I don't know how to copy a struct holding a closure. An…

akuendig
- 101
- 3
3
votes
2 answers
Passing a closure twice without it getting moved away
I'm experimenting with closures:
fn call_it(f: ||) {
f();
}
let klosure = || println("closure!");
call_it(klosure);
call_it(klosure); //Blows up here
Passing klosure into call_it() twice causes a compiler error on account of the closure value…

Greg Malcolm
- 3,238
- 4
- 23
- 24
3
votes
1 answer
Rust 0.9 -- Reading a file?
Here's what I'm trying to do: open all the command line arguments as (binary) files and read bytes from them. The constantly changing syntax here is not conductive to googling, but here's what I've figured out so far:
use std::io::{File,…

John Ledbetter
- 13,557
- 1
- 61
- 80
1
vote
1 answer
How do I make my struct fields mutable when accessing through a shared box ptr?
Editor's note: This code is from a version of Rust prior to 1.0 and is not syntactically or semantically valid Rust 1.0 code.
So, scoping out shared box pointers as a learning exercise. Purely academic exercise.
#[feature(managed_boxes)];
struct…

Greg Malcolm
- 3,238
- 4
- 23
- 24
0
votes
1 answer
unique vector patterns are no longer supported
I realize Rust is in flux, but I'm trying to learn it anyway. I'm trying to understand how I would adapt the following example, which works with 0.9, into something similar that works with 0.10:
fn main() {
let argv = std::os::args();
let…

pohl
- 3,158
- 1
- 30
- 48
0
votes
1 answer
How do I reverse a string in 0.9?
How do I reverse a string in Rust 0.9?
According to rosettacode.org this worked in 0.8:
let reversed:~str = "一二三四五六七八九十".rev_iter().collect();
... but I can't get iterators working on strings in 0.9.
Also tried std::str::StrSlice::bytes_rev but I…

Greg Malcolm
- 3,238
- 4
- 23
- 24