6565 ///
6666 /// [`create`]: Store::create
6767 /// [`load`]: Store::load
68- pub fn load < P > ( magic : & [ u8 ] , file_path : P ) -> Result < ( Option < C > , Self ) , StoreErrorWithDump < C > >
68+ pub fn load < P > ( magic : & [ u8 ] , file_path : P ) -> Result < ( Self , Option < C > ) , StoreErrorWithDump < C > >
6969 where
7070 P : AsRef < Path > ,
7171 {
9292 // Get aggregated changeset
9393 let aggregated_changeset = store. dump ( ) ?;
9494
95- Ok ( ( aggregated_changeset , store ) )
95+ Ok ( ( store , aggregated_changeset ) )
9696 }
9797
9898 /// Aggregate [`Store`] changesets and return them as a single changeset.
@@ -133,15 +133,15 @@ where
133133 pub fn load_or_create < P > (
134134 magic : & [ u8 ] ,
135135 file_path : P ,
136- ) -> Result < ( Option < C > , Self ) , StoreErrorWithDump < C > >
136+ ) -> Result < ( Self , Option < C > ) , StoreErrorWithDump < C > >
137137 where
138138 P : AsRef < Path > ,
139139 {
140140 if file_path. as_ref ( ) . exists ( ) {
141141 Self :: load ( magic, file_path)
142142 } else {
143143 Self :: create ( magic, file_path)
144- . map ( |store| ( Option :: < C > :: None , store ) )
144+ . map ( |store| ( store , Option :: < C > :: None ) )
145145 . map_err ( |err : StoreError | StoreErrorWithDump {
146146 changeset : Option :: < C > :: None ,
147147 error : err,
@@ -371,15 +371,15 @@ mod test {
371371 let changeset = BTreeSet :: from ( [ "hello" . to_string ( ) , "world" . to_string ( ) ] ) ;
372372
373373 {
374- let ( _ , mut store) =
374+ let ( mut store, _ ) =
375375 Store :: < TestChangeSet > :: load_or_create ( & TEST_MAGIC_BYTES , & file_path)
376376 . expect ( "must create" ) ;
377377 assert ! ( file_path. exists( ) ) ;
378378 store. append ( & changeset) . expect ( "must succeed" ) ;
379379 }
380380
381381 {
382- let ( recovered_changeset , _ ) =
382+ let ( _ , recovered_changeset ) =
383383 Store :: < TestChangeSet > :: load_or_create ( & TEST_MAGIC_BYTES , & file_path)
384384 . expect ( "must load" ) ;
385385 assert_eq ! ( recovered_changeset, Some ( changeset) ) ;
@@ -444,7 +444,7 @@ mod test {
444444
445445 // load file again - this time we should successfully aggregate all changesets
446446 {
447- let ( aggregated_changeset , _ ) =
447+ let ( _ , aggregated_changeset ) =
448448 Store :: < TestChangeSet > :: load ( & TEST_MAGIC_BYTES , & file_path) . unwrap ( ) ;
449449 assert_eq ! (
450450 aggregated_changeset,
@@ -480,7 +480,7 @@ mod test {
480480
481481 {
482482 // open store
483- let ( _ , mut store) = Store :: < TestChangeSet > :: load ( & TEST_MAGIC_BYTES , & file_path)
483+ let ( mut store, _ ) = Store :: < TestChangeSet > :: load ( & TEST_MAGIC_BYTES , & file_path)
484484 . expect ( "failed to load store" ) ;
485485
486486 // now append the second changeset
@@ -502,7 +502,7 @@ mod test {
502502 }
503503
504504 // Open the store again to verify file pointer position at the end of the file
505- let ( _ , mut store) = Store :: < TestChangeSet > :: load ( & TEST_MAGIC_BYTES , & file_path)
505+ let ( mut store, _ ) = Store :: < TestChangeSet > :: load ( & TEST_MAGIC_BYTES , & file_path)
506506 . expect ( "should load correctly" ) ;
507507
508508 // get the current position of file pointer just after loading store
0 commit comments