@@ -21,6 +21,7 @@ use rayon::prelude::*;
21
21
use schemars:: JsonSchema ;
22
22
use serde:: { Deserialize , Serialize } ;
23
23
//use std::cmp::Ordering;
24
+ //use anyhow::Result;
24
25
use std:: collections:: HashMap ;
25
26
use std:: fmt:: { self , Debug , Display , Formatter } ;
26
27
use std:: option:: Option ;
@@ -438,7 +439,8 @@ impl ComponentValues for TemplateContributor {
438
439
} else {
439
440
// TODO generalize the substitution
440
441
let add_role_form =
441
- options. global . substitute . clone ( ) . unwrap ( ) . contributor_role_form ;
442
+ // REVIEW is this correct?
443
+ options. global . substitute . clone ( ) ?. contributor_role_form ;
442
444
let editor = reference. editor ( ) ?;
443
445
let editor_length = editor. names ( options. global . clone ( ) , true ) . len ( ) ;
444
446
// get the role string; if it's in fact author, it will be None
@@ -449,16 +451,8 @@ impl ComponentValues for TemplateContributor {
449
451
role_form,
450
452
editor_length,
451
453
)
452
- // FIXME
453
- . unwrap ( )
454
454
} ) ;
455
- let suffix_padded = suffix. and_then ( |s| {
456
- if s. is_empty ( ) {
457
- None
458
- } else {
459
- Some ( format ! ( " {}" , s) )
460
- }
461
- } ) ; // TODO extract this into separate method
455
+ let suffix_padded = suffix. and_then ( |s| Some ( format ! ( " {}" , s?) ) ) ; // TODO extract this into separate method
462
456
Some ( ProcValues {
463
457
value : editor. format ( options. global . clone ( ) , locale) ,
464
458
prefix : None ,
@@ -565,7 +559,11 @@ impl ComponentValues for TemplateDate {
565
559
566
560
// TODO: implement this along with localized dates
567
561
fn _config_fmt ( options : & RenderOptions ) -> DateTimeFormatterOptions {
568
- match options. global . dates . as_ref ( ) . unwrap ( ) . month {
562
+ let date_options = match options. global . dates . clone ( ) {
563
+ Some ( dates) => dates,
564
+ None => return DateTimeFormatterOptions :: default ( ) , // or handle the None case accordingly
565
+ } ;
566
+ match date_options. month {
569
567
MonthFormat :: Long => todo ! ( "long" ) ,
570
568
MonthFormat :: Short => todo ! ( "short" ) ,
571
569
MonthFormat :: Numeric => todo ! ( "numeric" ) ,
@@ -584,7 +582,7 @@ impl ComponentValues for TemplateDate {
584
582
// TODO need to check form here also
585
583
// && self.form == style::template::DateForm::Year
586
584
// REVIEW: ugly, and needs to be smarter
587
- && options. global . processing . clone ( ) . unwrap ( ) . config ( ) . disambiguate . unwrap ( ) . year_suffix
585
+ && options. global . processing . clone ( ) . unwrap_or_default ( ) . config ( ) . disambiguate . unwrap_or_default ( ) . year_suffix
588
586
&& formatted_date. len ( ) == 4
589
587
{
590
588
int_to_letter ( ( hints. group_index % 26 ) as u32 )
@@ -673,7 +671,10 @@ impl Processor {
673
671
) -> Option < ProcCitationItem > {
674
672
let citation_style = self . style . citation . clone ( ) ;
675
673
// FIXME below is returning None
676
- let reference = self . get_reference ( & citation_item. ref_id ) . unwrap ( ) ;
674
+ let reference = match self . get_reference ( & citation_item. ref_id ) {
675
+ Ok ( reference) => reference,
676
+ Err ( _) => return None , // or handle the error in a different way
677
+ } ;
677
678
let proc_template =
678
679
self . process_template ( & reference, citation_style?. template . as_slice ( ) ) ;
679
680
println ! ( "proc_template: {:?}" , proc_template) ;
@@ -685,9 +686,9 @@ impl Processor {
685
686
& self ,
686
687
reference : & InputReference ,
687
688
) -> Vec < ProcTemplateComponent > {
688
- let bibliography_style = self . style . bibliography . clone ( ) ;
689
+ let bibliography_style = self . style . bibliography . clone ( ) . unwrap ( ) ;
689
690
// TODO bibliography should probably be Optional
690
- self . process_template ( reference, bibliography_style. unwrap ( ) . template . as_slice ( ) )
691
+ self . process_template ( reference, bibliography_style. template . as_slice ( ) )
691
692
}
692
693
693
694
fn get_render_options ( & self , style : Style , locale : Locale ) -> RenderOptions {
0 commit comments