Add helper to build file from Parser return value

This commit is contained in:
Matthias Beyer 2015-11-24 10:58:54 +01:00
parent 8808e911c8
commit 4464c32b98

View file

@ -185,6 +185,18 @@ impl File {
}
}
pub fn from_parser_result(id: FileID, r: Result<(FileHeaderData, String), ParserError>) -> Option<File> {
if let Ok((header, data)) = r {
Some(File {
header: header,
data: data,
id: id,
})
} else {
None
}
}
pub fn new_with_header(h: FileHeaderData) -> File {
File {
header: h,