Days in Month solution The code, written in Rust, solves the Days in Month problem in CodeChef. It is also one of my first few programs written in Rust.

The code is accepted so that there are no logical mistakes. I am more interested in getting review feedback on style. I am not particularly happy with the code as is; it is rather bulky.

use std::io;

fn read_line(stdin: &amp;io::Stdin) -&gt; io::Result&lt;String&gt;
{
    let mut input = String::new();
    match stdin.read_line(&amp;mut input)
    {
        Ok(_) =&gt; Ok(input.trim().to_string()),
        Err(e) =&gt; Err(e)
    }
}

fn to_day_of_week(input: &amp;str) -&gt; Option&lt;usize&gt;
{
    if input == "mon"
    {
        Some(0)
    }
    else if input == "tues"
    {
        Some(1)
    }
    else if input == "wed"
    {
        Some(2)
    }
    else if input == "thurs"
    {
        Some(3)
    }
    else if input == "fri"
    {
        Some(4)
    }
    else if input == "sat"
    {
        Some(5)
    }
    else if input == "sun"
    {
        Some(6)
    }
    else
    { 
        None
    }
}

pub fn codechef_nw1()
{
    let stdin = io::stdin();
    let read_first_line_result = read_line(&amp;stdin);
    if read_first_line_result.is_ok()
    {
        let first_line = read_first_line_result.unwrap();
        let parse_first_line_result = first_line.parse::&lt;i32&gt;();
        if parse_first_line_result.is_ok()
        {
            let t = parse_first_line_result.unwrap();
            for _i in 0..t
            {
                let read_test_line_result = read_line(&amp;stdin);
                if read_test_line_result.is_ok()
                {
                    let test_line = read_test_line_result.unwrap();
                    let find_space_result = test_line.find(' ');
                    if find_space_result.is_some()
                    {
                        let space_index = find_space_result.unwrap();
                        let test_token_1 = &amp;test_line[..space_index];
                        let test_token_2 = &amp;test_line[space_index + 1..];
                        let parse_day_result = test_token_1.parse::&lt;i32&gt;();
                        if parse_day_result.is_ok()
                        {
                            let days = parse_day_result.unwrap();
                            let day_of_week_result = to_day_of_week(test_token_2);
                            if day_of_week_result.is_some()
                            {
                                let mut day_of_week = day_of_week_result.unwrap();
                                let mut stats = [0, 0, 0, 0, 0, 0, 0];
                                for _d in 0..days
                                {
                                    stats[day_of_week] = stats[day_of_week] + 1;
                                    day_of_week = day_of_week + 1;
                                    day_of_week = day_of_week % 7;
                                }
                                println!("{} {} {} {} {} {} {}", stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[6]);
                            }                            
                        }
                    }
                }
            }
        }
    }
}
to_day_of_week can be heavily simplified by using match instead of if-else:

fn to_day_of_week(input: &amp;str) -&gt; Option&lt;usize&gt; {
    match input {
        "mon" =&gt; Some(0),
        "tues" =&gt; Some(1),
        "wed" =&gt; Some(2),
        "thurs" =&gt; Some(3),
        "fri" =&gt; Some(4),
        "sat" =&gt; Some(5),
        "sun" =&gt; Some(6),
        _ =&gt; None,
    }
}


The bulkiness of your code can be somewhat helped if you provide additional functions and use ? instead of unwrap. Using unwrap is discouraged, as far as I know. If you don't want to use ? or additional functions, early returns prevent your code from getting too much indented.