From 4464c32b982a404fab507f75797f45ad30844318 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 24 Nov 2015 10:58:54 +0100 Subject: [PATCH] Add helper to build file from Parser return value --- src/storage/file.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/storage/file.rs b/src/storage/file.rs index 81a7b1a7..5ef73fb7 100644 --- a/src/storage/file.rs +++ b/src/storage/file.rs @@ -185,6 +185,18 @@ impl File { } } + pub fn from_parser_result(id: FileID, r: Result<(FileHeaderData, String), ParserError>) -> Option { + 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,