Simple function to create Tokens from user input
It's not clear whether you want to support only y, n and numbers as your question states, or any characters besides y &amp; n as your code implies :)

Basically you can divide the problem to two sub problems:


Split the input string to words I'm using the split methods from std but if you have more complex requirements, you can use the regex crate 
Map the words to tokens. A simple equality check (==) or match is enough. There is no need to parse() everything. 


As you've not specified what's allowed as a delimiter, I'll assume that it's whitespace. 

#[derive(Debug)]
enum InputToken {
    Number(i64),
    Boolean(bool),
    Error(String),
}

fn main() {
    let input = "1 -2 +4 y n &amp; abc";
    let tokens = input.split_whitespace();

    for x in tokens {
        println!("{:?}", parse_token(x));
    }
}

fn parse_token(input: &amp;str) -&gt; InputToken {
    match input {
        "y" =&gt; InputToken::Boolean(true),
        "n" =&gt; InputToken::Boolean(false),
        token =&gt; match token.parse::&lt;i64&gt;() {
            Ok(num) =&gt; InputToken::Number(num),
            Err(e) =&gt; InputToken::Error(format!("Invalid input token [{}]: {:?}", token, e))
    }
}


}