Add helper to build file from Parser return value
This commit is contained in:
parent
8808e911c8
commit
4464c32b98
1 changed files with 12 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue