Rewrite internal linking handling to use less unwrap()
This commit is contained in:
parent
fa64c2d27d
commit
b90dabaa97
1 changed files with 66 additions and 69 deletions
|
@ -88,9 +88,10 @@ fn handle_internal_linking(rt: &Runtime) {
|
||||||
debug!("Handle internal linking call");
|
debug!("Handle internal linking call");
|
||||||
let cmd = rt.cli().subcommand_matches("internal").unwrap();
|
let cmd = rt.cli().subcommand_matches("internal").unwrap();
|
||||||
|
|
||||||
if cmd.is_present("list") {
|
match cmd.value_of("list") {
|
||||||
|
Some(list) => {
|
||||||
debug!("List...");
|
debug!("List...");
|
||||||
for entry in cmd.value_of("list").unwrap().split(',') {
|
for entry in list.split(',') {
|
||||||
debug!("Listing for '{}'", entry);
|
debug!("Listing for '{}'", entry);
|
||||||
match get_entry_by_name(rt, entry) {
|
match get_entry_by_name(rt, entry) {
|
||||||
Ok(Some(e)) => {
|
Ok(Some(e)) => {
|
||||||
|
@ -124,22 +125,17 @@ fn handle_internal_linking(rt: &Runtime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!("Listing ready!");
|
debug!("Listing ready!");
|
||||||
} else {
|
},
|
||||||
let mut from = {
|
None => {
|
||||||
let from = get_from_entry(&rt);
|
let mut from = match get_from_entry(&rt) {
|
||||||
if from.is_none() {
|
None => warn_exit("No 'from' entry", 1),
|
||||||
warn_exit("No 'from' entry", 1);
|
Some(s) => s,
|
||||||
}
|
|
||||||
from.unwrap()
|
|
||||||
};
|
};
|
||||||
debug!("Link from = {:?}", from.deref());
|
debug!("Link from = {:?}", from.deref());
|
||||||
|
|
||||||
let to = {
|
let to = match get_to_entries(&rt) {
|
||||||
let to = get_to_entries(&rt);
|
None => warn_exit("No 'to' entry", 1),
|
||||||
if to.is_none() {
|
Some(to) => to,
|
||||||
warn_exit("No 'to' entry", 1);
|
|
||||||
}
|
|
||||||
to.unwrap()
|
|
||||||
};
|
};
|
||||||
debug!("Link to = {:?}", to.iter().map(|f| f.deref()).collect::<Vec<&Entry>>());
|
debug!("Link to = {:?}", to.iter().map(|f| f.deref()).collect::<Vec<&Entry>>());
|
||||||
|
|
||||||
|
@ -163,6 +159,7 @@ fn handle_internal_linking(rt: &Runtime) {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_from_entry<'a>(rt: &'a Runtime) -> Option<FileLockEntry<'a>> {
|
fn get_from_entry<'a>(rt: &'a Runtime) -> Option<FileLockEntry<'a>> {
|
||||||
|
|
Loading…
Reference in a new issue