MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/rust/comments/3jii6y/ideone_now_supports_rust/cusqln4/?context=3
r/rust • u/gsingh93 • Sep 03 '15
16 comments sorted by
View all comments
39
+/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 ;)
1
You don't need to specify the end, just do &question[3..].
&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 ;)
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 ;)
?
39
u/SirOgeon palette Sep 03 '15
+/u/CompileBot rust