@@ -20,8 +20,10 @@ macro_rules! get_item_from {
20
20
( $oid: expr, $repo: expr, $typs: ident) => {
21
21
git_repository:: hash:: ObjectId :: from( $oid)
22
22
. attach( & $repo)
23
- . object( ) . map_err( |_| "Could not find object" ) ?
24
- . $typs( ) . map_err( |_| format!( "Could not find {} from object" , stringify!( $typs) ) ) ?
23
+ . object( )
24
+ . map_err( |_| "Could not find object" ) ?
25
+ . $typs( )
26
+ . map_err( |_| format!( "Could not find {} from object" , stringify!( $typs) ) ) ?
25
27
} ;
26
28
}
27
29
@@ -414,8 +416,11 @@ fn traverse_tree(
414
416
}
415
417
} ,
416
418
}
417
- let obh = repo. find_object ( i. oid ( ) ) . map_err ( |_| "failed to find object" ) ?;
418
- let objref = objs:: ObjectRef :: from_bytes ( obh. kind , & obh. data ) . map_err ( |_| "failed to get object ref" ) ?;
419
+ let obh = repo
420
+ . find_object ( i. oid ( ) )
421
+ . map_err ( |_| "failed to find object" ) ?;
422
+ let objref = objs:: ObjectRef :: from_bytes ( obh. kind , & obh. data )
423
+ . map_err ( |_| "failed to get object ref" ) ?;
419
424
let blob = objref. into_blob ( ) ;
420
425
if let Some ( blob) = blob {
421
426
files. push ( ( file, String :: from_utf8_lossy ( blob. data ) . to_string ( ) ) ) ;
@@ -534,7 +539,7 @@ fn find_function_in_file_with_commit(
534
539
) -> Result < FileType , String > {
535
540
let file = match langs {
536
541
Language :: Rust => {
537
- let functions = rust:: find_function_in_file ( fc, name) ?;
542
+ let functions = rust:: find_function_in_file ( fc, name) ?;
538
543
FileType :: Rust ( RustFile :: new ( file_path. to_string ( ) , functions) )
539
544
}
540
545
// #[cfg(feature = "c_lang")]
@@ -544,25 +549,24 @@ fn find_function_in_file_with_commit(
544
549
// }
545
550
#[ cfg( feature = "unstable" ) ]
546
551
Language :: Go => {
547
- let functions = languages:: go:: find_function_in_file ( fc, name) ?;
552
+ let functions = languages:: go:: find_function_in_file ( fc, name) ?;
548
553
FileType :: Go ( GoFile :: new ( file_path. to_string ( ) , functions) )
549
554
}
550
555
Language :: Python => {
551
- let functions = languages:: python:: find_function_in_file ( fc, name) ?;
556
+ let functions = languages:: python:: find_function_in_file ( fc, name) ?;
552
557
FileType :: Python ( PythonFile :: new ( file_path. to_string ( ) , functions) )
553
558
}
554
559
Language :: Ruby => {
555
- let functions = languages:: ruby:: find_function_in_file ( fc, name) ?;
560
+ let functions = languages:: ruby:: find_function_in_file ( fc, name) ?;
556
561
FileType :: Ruby ( RubyFile :: new ( file_path. to_string ( ) , functions) )
557
562
}
558
563
Language :: UMPL => {
559
- let functions = languages:: umpl:: find_function_in_file ( fc, name) ?;
564
+ let functions = languages:: umpl:: find_function_in_file ( fc, name) ?;
560
565
FileType :: UMPL ( UMPLFile :: new ( file_path. to_string ( ) , functions) )
561
566
}
562
567
Language :: All => match file_path. split ( '.' ) . last ( ) {
563
568
Some ( "rs" ) => {
564
-
565
- let functions = rust:: find_function_in_file ( fc, name) ?;
569
+ let functions = rust:: find_function_in_file ( fc, name) ?;
566
570
FileType :: Rust ( RustFile :: new ( file_path. to_string ( ) , functions) )
567
571
}
568
572
// #[cfg(feature = "c_lang")]
@@ -571,16 +575,16 @@ fn find_function_in_file_with_commit(
571
575
// FileType::C(CFile::new(file_path.to_string(), functions))
572
576
// }
573
577
Some ( "py" | "pyw" ) => {
574
- let functions = languages:: python:: find_function_in_file ( fc, name) ?;
578
+ let functions = languages:: python:: find_function_in_file ( fc, name) ?;
575
579
FileType :: Python ( PythonFile :: new ( file_path. to_string ( ) , functions) )
576
580
}
577
581
#[ cfg( feature = "unstable" ) ]
578
582
Some ( "go" ) => {
579
- let functions = languages:: go:: find_function_in_file ( fc, name) ?;
583
+ let functions = languages:: go:: find_function_in_file ( fc, name) ?;
580
584
FileType :: Go ( GoFile :: new ( file_path. to_string ( ) , functions) )
581
585
}
582
586
Some ( "rb" ) => {
583
- let functions = languages:: ruby:: find_function_in_file ( fc, name) ?;
587
+ let functions = languages:: ruby:: find_function_in_file ( fc, name) ?;
584
588
FileType :: Ruby ( RubyFile :: new ( file_path. to_string ( ) , functions) )
585
589
}
586
590
_ => Err ( "unknown file type" ) ?,
@@ -618,7 +622,6 @@ trait UnwrapToError<T> {
618
622
}
619
623
620
624
impl < T > UnwrapToError < T > for Option < T > {
621
-
622
625
fn unwrap_to_error ( self , message : & str ) -> Result < T , String > {
623
626
self . map_or_else ( || Err ( message. to_string ( ) ) , |val| Ok ( val) )
624
627
}
0 commit comments