[rust-dev] user input

2014-02-08 Thread Renato Lenzi
I would like to manage user input for example by storing it in a string. I found this solution: use std::io::buffered::BufferedReader; use std::io::stdin; fn main() { let mut stdin = BufferedReader::new(stdin()); let mut s1 = stdin.read_line().unwrap_or(~nothing); print(s1); } It

Re: [rust-dev] user input

2014-02-08 Thread Alex Crichton
We do indeed want to make common tasks like this fairly lightweight, but we also strive to require that the program handle possible error cases. Currently, the code you have shows well what one would expect when reading a line of input. On today's master, you might be able to shorten it slightly

Re: [rust-dev] user input

2014-02-08 Thread Lee Braiden
On 08/02/14 23:35, Alex Crichton wrote: I'm curious thought what you think is the heavy/verbose aspects of this? I like common patterns having shortcuts here and there! When reading the original post, it did occur to me that there should probably be a readln() equivalent of println(), if only

Re: [rust-dev] How to use dynamic polymorphism with collection

2014-02-08 Thread Ashish Myles
On Sat, Feb 8, 2014 at 6:48 PM, Ashish Myles marci...@gmail.com wrote: On Sat, Feb 8, 2014 at 1:21 PM, Philippe Delrieu philippe.delr...@free.fr wrote: pub trait Base { fn do_base(self); } struct TestBase; impl Base for TestBase{ fn do_base(self){

Re: [rust-dev] user input

2014-02-08 Thread Renato Lenzi
I believe that reading a string from console should be considered one of the simplest task to perform. Ok i do not pretend a sintax like s1 = input() ala Python but perhaps somehting like string s1 = Console.Readline(); as in C# mode would be sufficient for a basic input control... sure,

Re: [rust-dev] user input

2014-02-08 Thread Liigo Zhuang
2014年2月9日 上午7:35于 Alex Crichton a...@crichton.co写道: We do indeed want to make common tasks like this fairly lightweight, but we also strive to require that the program handle possible error cases. Currently, the code you have shows well what one would expect when reading a line of input. On

Re: [rust-dev] user input

2014-02-08 Thread Huon Wilson
There is read_line: http://static.rust-lang.org/doc/master/std/io/trait.Buffer.html#method.read_line use std::io::{stdin, BufferedReader}; fn main() { let mut stdin = BufferedReader::new(stdin()); let line = stdin.read_line().unwrap(); println!({}, line); }

Re: [rust-dev] user input

2014-02-08 Thread Sean McArthur
let in = readln!() ? macro_rules! readln( () = ({ let mut stdin = ::std::io::BufferedReader::new(::std::io::stdin()); stdin.read_line().unwrap() }) ) On Sat, Feb 8, 2014 at 4:48 PM, Huon Wilson dbau...@gmail.com wrote: There is read_line:

Re: [rust-dev] Rust meetup in Paris @MozSpace - 25 February 2014

2014-02-08 Thread Nicolas Silva
I don't want to discourage English speakers so I think we should do it in English and optionally switch to French depending on the audience. I have been to a few hacker meetups in Paris where the language of choice for presentations was English (even though 90% of the attendees were French) and it

Re: [rust-dev] user input

2014-02-08 Thread Patrick Walton
On 2/8/14 3:35 PM, Alex Crichton wrote: We do indeed want to make common tasks like this fairly lightweight, but we also strive to require that the program handle possible error cases. Currently, the code you have shows well what one would expect when reading a line of input. On today's master,