Make data representation more flexible
This commit is contained in:
parent
49b27715f0
commit
67f405a21e
3 changed files with 87 additions and 72 deletions
|
|
@ -8,7 +8,7 @@ use crate::util;
|
|||
pub fn path(datafile: &Path, from: &str, to: &str) -> io::Result<()> {
|
||||
eprintln!(">> Import");
|
||||
let mut databuf = BufReader::new(File::open(datafile)?);
|
||||
let mut data = AdjacencyList::read(&mut databuf)?.change_page_data(f32::INFINITY);
|
||||
let data = AdjacencyList::read(&mut databuf)?;
|
||||
|
||||
eprintln!(">> Locate from and to");
|
||||
let from = util::normalize_link(from);
|
||||
|
|
@ -17,15 +17,15 @@ pub fn path(datafile: &Path, from: &str, to: &str) -> io::Result<()> {
|
|||
.pages
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, p)| !p.redirect)
|
||||
.find(|(_, p)| util::normalize_link(&p.title) == from)
|
||||
.filter(|(_, p)| !p.data.redirect)
|
||||
.find(|(_, p)| util::normalize_link(&p.data.title) == from)
|
||||
.unwrap_or_else(|| panic!("no article called {from}"));
|
||||
let (to_i, to_p) = data
|
||||
.pages
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, p)| !p.redirect)
|
||||
.find(|(_, p)| util::normalize_link(&p.title) == to)
|
||||
.filter(|(_, p)| !p.data.redirect)
|
||||
.find(|(_, p)| util::normalize_link(&p.data.title) == to)
|
||||
.unwrap_or_else(|| panic!("no article called {to}"));
|
||||
dbg!(from_i, from_p, to_i, to_p);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue