Skip to content

Can't use with Rust 2015 edition #248

@RazrFalcon

Description

@RazrFalcon

I have a code roughly like this:

fn parse_selectors<'i, 't>(
    input: &mut Parser<'i, 't>,
) -> Result<String, ParseError<'i, CustomParseError>> {
    let mut selectors = String::new();
    while let Ok(t) = input.next() {
        match t {
            Token::SquareBracketBlock => {
                selectors.push('[');

                input.parse_nested_block(|p| {
                    while let Ok(t) = p.next() {
                        /// ... 
                    }

                    Ok(())
                })?;

                selectors.push(']');
            }

            t => {
                unreachable!()
            }
        }
    }

    Ok(selectors)
}

It works fine with Rust 2018, but with 2015 I'm getting:

error[E0499]: cannot borrow `*input` as mutable more than once at a time
   --> src/lib.rs:134:17
    |
98  |     while let Ok(t) = input.next() {
    |                       -----      - first borrow ends here
    |                       |
    |                       first mutable borrow occurs here
...
134 |                 input.parse_nested_block(|p| {
    |                 ^^^^^ second mutable borrow occurs here

Is it not possible at all on Rust 2015 or I have to change a code somehow?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions