Make Entry::{from_file,from_str} generic over IntoStoreId

This commit is contained in:
Matthias Beyer 2016-05-04 12:00:31 +02:00
parent 79f585def9
commit 3842e177d7

View file

@ -1119,7 +1119,7 @@ impl Entry {
} }
} }
pub fn from_file(loc: StoreId, file: &mut File) -> Result<Entry> { pub fn from_file<S: IntoStoreId>(loc: S, file: &mut File) -> Result<Entry> {
let text = { let text = {
use std::io::Read; use std::io::Read;
let mut s = String::new(); let mut s = String::new();
@ -1129,7 +1129,7 @@ impl Entry {
Self::from_str(loc, &text[..]) Self::from_str(loc, &text[..])
} }
pub fn from_str(loc: StoreId, s: &str) -> Result<Entry> { pub fn from_str<S: IntoStoreId>(loc: S, s: &str) -> Result<Entry> {
debug!("Building entry from string"); debug!("Building entry from string");
lazy_static! { lazy_static! {
static ref RE: Regex = Regex::new(r"(?smx) static ref RE: Regex = Regex::new(r"(?smx)
@ -1157,7 +1157,7 @@ impl Entry {
debug!("Header and content found. Yay! Building Entry object now"); debug!("Header and content found. Yay! Building Entry object now");
Ok(Entry { Ok(Entry {
location: loc, location: loc.into_storeid(),
header: try!(EntryHeader::parse(header.unwrap())), header: try!(EntryHeader::parse(header.unwrap())),
content: content.into(), content: content.into(),
}) })