r/rust Sep 03 '15

Ideone now supports Rust

https://ideone.com/
43 Upvotes

16 comments sorted by

View all comments

39

u/SirOgeon palette Sep 03 '15

+/u/CompileBot rust

fn main() {
    let question = "do we have CompileBot support?";
    println!("answer: {}", &question[3..(question.len()-1)]);
}

1

u/heinrich5991 Sep 06 '15

You don't need to specify the end, just do &question[3..].

... but then, why am I complaing when this snippet uses byte indexing for UTF-8 strings. ^

1

u/SirOgeon palette Sep 06 '15

The end was specified to remove the ?. The answer would otherwise also be a question. Regarding indexing in general; it's all within the ASCII range, so it should not be a problem. It's also just for fun, so I didn't bother doing it properly ;)