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, it's
more readable... but actually the thing that puzzles me is that you cannot
 write something like:

let mut s1 = stdin.read_line();

cause the compiler complains (why?)....it's a matter of taste, of course.

Regards


On Sun, Feb 9, 2014 at 12:35 AM, Alex Crichton <a...@crichton.co> 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, you might be able to
> shorten it slightly to:
>
>     use std::io::{stdin, BufferedReader};
>
>     fn main() {
>         let mut stdin = BufferedReader::new(stdin());
>         for line in stdin.lines() {
>             println!("{}", line);
>         }
>     }
>
> I'm curious thought what you think is the heavy/verbose aspects of
> this? I like common patterns having shortcuts here and there!
>
> On Sat, Feb 8, 2014 at 3:06 PM, Renato Lenzi <rex...@gmail.com> wrote:
> > 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 works but it seems (to me) a bit verbose, heavy... is there a cheaper
> way
> > to do this simple task?
> >
> > Thx.
> >
> > _______________________________________________
> > Rust-dev mailing list
> > Rust-dev@mozilla.org
> > https://mail.mozilla.org/listinfo/rust-dev
> >
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to