diff options
| author | lukeflo | 2024-10-17 13:12:16 +0200 |
|---|---|---|
| committer | lukeflo | 2024-10-17 13:12:16 +0200 |
| commit | d54b08f8fbe372afdd9b4bc3e366555ebdef4372 (patch) | |
| tree | ee229f98572f2fcace4284dd3d8c0cbfbe170d4e /src | |
| parent | c555c8666268efdff4d7107d5a527b899679559e (diff) | |
| download | bibiman-d54b08f8fbe372afdd9b4bc3e366555ebdef4372.tar.gz bibiman-d54b08f8fbe372afdd9b4bc3e366555ebdef4372.zip | |
simplify get_authors func
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend/bib.rs | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/src/backend/bib.rs b/src/backend/bib.rs index fecb548..8539ab3 100644 --- a/src/backend/bib.rs +++ b/src/backend/bib.rs @@ -170,39 +170,36 @@ impl BibiEntry { } pub fn get_authors(citekey: &str, biblio: &Bibliography) -> String { - let authors = { - if biblio.get(&citekey).unwrap().author().is_ok() { - let authors = biblio.get(&citekey).unwrap().author().unwrap(); - if authors.len() > 1 { - let authors = format!("{} et al.", authors[0].name); - authors - } else if authors.len() == 1 { - let authors = authors[0].name.to_string(); - authors - } else { - let editors_authors = format!("empty"); - editors_authors - } + if biblio.get(&citekey).unwrap().author().is_ok() { + let authors = biblio.get(&citekey).unwrap().author().unwrap(); + if authors.len() > 1 { + let authors = format!("{} et al.", authors[0].name); + authors + } else if authors.len() == 1 { + let authors = authors[0].name.to_string(); + authors } else { - if biblio.get(&citekey).unwrap().editors().is_ok() { - let editors = biblio.get(&citekey).unwrap().editors().unwrap(); - if editors.len() > 1 { - let editors = format!("{} (ed.) et al.", editors[0].0[0].name); - editors - } else if editors.len() == 1 { - let editors = format!("{} (ed.)", editors[0].0[0].name); - editors - } else { - let editors_authors = format!("empty"); - editors_authors - } + let editors_authors = format!("empty"); + editors_authors + } + } else { + if biblio.get(&citekey).unwrap().editors().is_ok() { + let editors = biblio.get(&citekey).unwrap().editors().unwrap(); + if editors.len() > 1 { + let editors = format!("{} (ed.) et al.", editors[0].0[0].name); + editors + } else if editors.len() == 1 { + let editors = format!("{} (ed.)", editors[0].0[0].name); + editors } else { let editors_authors = format!("empty"); editors_authors } + } else { + let editors_authors = format!("empty"); + editors_authors } - }; - authors + } } pub fn get_title(citekey: &str, biblio: &Bibliography) -> String { |
