Closed
Description
I get:
$ rustc structmatch.rs --test
structmatch.rs:24:7: 24:18 error: `ParseFailed` does not name a structure
structmatch.rs:24 Err(ParseFailed{file: f, line: y, col: x, mesg: txt}) => assert x == 6,
^~~~~~~~~~~
error: aborting due to previous error
with this:
extern mod std; // else --test goes wonky
extern mod rparse; // https://github.com/jesse99/rparse or: cargo install rparse
use rparse::{Parser, Combinators, ParseFailed, match0 };
pub fn space() -> Parser<@~str> { match0(|ch| ws_char.contains_char(ch)) }
const ws_char: &str = &" \t\r\n\x0A";
#[cfg(test)]
mod test_preliminaries {
// This shows ParseFailed is correctly imported.
fn mk_failed() -> ParseFailed {
ParseFailed{file: @~"", line: 1, col: 2, mesg: @~"hello"}
}
#[test]
fn match_problemr() {
let actual = space()
.parse(@~"f", @"$( x \u0000 is not allowed $)");
match actual {
Ok(_) => fail,
Err(ParseFailed{file: f, line: y, col: x, mesg: txt}) => assert x == 6,
// The with the line below in place of the one above, this compiles.
//Err(_) => ()
}
}
}
current revision of rparse is:
commit 1c6f5e8a15dd9d4972fcbf8692ebe79cc72d4b46
Author: Jesse Jones
Date: Wed Oct 17 07:05:59 2012 -0700
Meanwhile, this compiles fine...
extern mod std; // else --test goes wonky
struct ParseFailed {
file: @~str,
line: uint,
col: uint,
mesg: @~str
}
type ParseResult = Result<int, ParseFailed>;
fn match_problem() {
let actual: ParseResult = Ok(1);
match actual {
Ok(_) => fail,
Err(ParseFailed{file: f, line: y, col: x, mesg: txt}) => assert x == 6,
}
}