diff options
Diffstat (limited to 'src/libsyntax/parse/token.rs')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 2c5698ddec4..ff1509fe23a 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -297,21 +297,17 @@ pub fn can_begin_expr(t: &Token) -> bool { } } -/// what's the opposite delimiter? -pub fn flip_delimiter(t: &token::Token) -> token::Token { +/// Returns the matching close delimiter if this is an open delimiter, +/// otherwise `None`. +pub fn close_delimiter_for(t: &Token) -> Option<Token> { match *t { - LPAREN => RPAREN, - LBRACE => RBRACE, - LBRACKET => RBRACKET, - RPAREN => LPAREN, - RBRACE => LBRACE, - RBRACKET => LBRACKET, - _ => fail!() + LPAREN => Some(RPAREN), + LBRACE => Some(RBRACE), + LBRACKET => Some(RBRACKET), + _ => None } } - - pub fn is_lit(t: &Token) -> bool { match *t { LIT_CHAR(_) => true, |
