Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support parsing half-open ranges in patterns. #128

Merged
merged 1 commit into from
Apr 30, 2017
Merged

Support parsing half-open ranges in patterns. #128

merged 1 commit into from
Apr 30, 2017

Conversation

Arnavion
Copy link
Contributor

Fixes #117

@dtolnay
Copy link
Owner

dtolnay commented Apr 25, 2017

Looks good to me but hmm, any idea why libsyntax uses two different enums for Expr ranges vs Pat ranges?

pub enum ExprKind {
    /* ... */

    /// A range (`1..2`, `1..`, `..2`, `1...2`, `1...`, `...2`)
    Range(Option<P<Expr>>, Option<P<Expr>>, RangeLimits),
}

/// Limit types of a range (inclusive or exclusive)
pub enum RangeLimits {
    /// Inclusive at the beginning, exclusive at the end
    HalfOpen,
    /// Inclusive at the beginning and end
    Closed,
}

pub enum PatKind {
    /* ... */

    /// A range pattern, e.g. `1...2` or `1..2`
    Range(P<Expr>, P<Expr>, RangeEnd),
}

pub enum RangeEnd {
    Included,
    Excluded,
}

@Arnavion
Copy link
Contributor Author

Nothing that's obvious from the commit message or PR discussion. @oli-obk ?

@oli-obk
Copy link

oli-obk commented Apr 25, 2017

I think the answer is rather obvious: I didn't know about RangeLimits... XD

@dtolnay dtolnay merged commit 0e94f0e into dtolnay:master Apr 30, 2017
@Arnavion Arnavion deleted the half-open-pat branch April 30, 2017 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants