11use core:: ops:: Index ;
22
33use super :: { Habitat , LineageReference } ;
4- use crate :: landscape:: Location ;
4+ use crate :: landscape:: { IndexedLocation , Location } ;
55use crate :: lineage:: Lineage ;
66
77mod contract;
@@ -58,8 +58,9 @@ pub trait CoherentLineageStore<H: Habitat, R: LineageReference<H>>: LineageStore
5858 contract:: explicit_lineage_store_invariant_contract( self , & location) ,
5959 "invariant of lineage-location bijection holds"
6060 ) ]
61+ #[ debug_ensures( self [ old( reference. clone( ) ) ] . is_active( ) , "lineage was activated" ) ]
6162 #[ debug_ensures(
62- self [ old( reference. clone( ) ) ] . location ( ) == Some ( & old( location. clone( ) ) ) ,
63+ self [ old( reference. clone( ) ) ] . indexed_location ( ) . map ( IndexedLocation :: location ) == Some ( & old( location. clone( ) ) ) ,
6364 "lineage was added to location"
6465 ) ]
6566 #[ debug_ensures(
@@ -82,24 +83,25 @@ pub trait CoherentLineageStore<H: Habitat, R: LineageReference<H>>: LineageStore
8283 ) ]
8384 #[ debug_requires(
8485 contract:: explicit_lineage_store_invariant_contract(
85- self , self [ reference. clone( ) ] . location ( ) . unwrap( )
86+ self , self [ reference. clone( ) ] . indexed_location ( ) . unwrap( ) . location ( )
8687 ) , "invariant of lineage-location bijection holds"
8788 ) ]
89+ #[ debug_ensures( !self [ old( reference. clone( ) ) ] . is_active( ) , "lineage was deactivated" ) ]
8890 #[ debug_ensures(
8991 !contract:: explicit_lineage_store_lineage_at_location_contract(
9092 self , old( reference. clone( ) )
9193 ) , "lineage was removed from the location and index it references"
9294 ) ]
9395 #[ debug_ensures(
9496 contract:: explicit_lineage_store_invariant_contract(
95- self , & old( self [ reference. clone( ) ] . location ( ) . unwrap( ) . clone( ) )
97+ self , & old( self [ reference. clone( ) ] . indexed_location ( ) . unwrap( ) . location ( ) . clone( ) )
9698 ) , "maintains invariant of lineage-location bijection"
9799 ) ]
98100 #[ debug_ensures(
99- ret == old( self [ reference. clone( ) ] . location ( ) . unwrap( ) . clone( ) ) ,
100- "returns the individual's prior location "
101+ ret == old( self [ reference. clone( ) ] . indexed_location ( ) . unwrap( ) . clone( ) ) ,
102+ "returns the individual's prior indexed_location "
101103 ) ]
102- fn pop_lineage_from_its_location ( & mut self , reference : R ) -> Location ;
104+ fn pop_lineage_from_its_location ( & mut self , reference : R ) -> IndexedLocation ;
103105}
104106
105107#[ allow( clippy:: inline_always, clippy:: inline_fn_without_body) ]
@@ -108,59 +110,24 @@ pub trait CoherentLineageStore<H: Habitat, R: LineageReference<H>>: LineageStore
108110pub trait IncoherentLineageStore < H : Habitat , R : LineageReference < H > > : LineageStore < H , R > {
109111 #[ debug_requires( self . get( reference. clone( ) ) . is_some( ) , "lineage reference is valid" ) ]
110112 #[ debug_requires( !self [ reference. clone( ) ] . is_active( ) , "lineage is inactive" ) ]
111- /*#[debug_requires(
112- !contract::explicit_lineage_store_lineage_at_location_contract(self, reference.clone()),
113- "lineage is not at the location and index it references"
114- )]
115- #[debug_requires(
116- contract::explicit_lineage_store_invariant_contract(self, &location),
117- "invariant of lineage-location bijection holds"
118- )]
113+ #[ debug_ensures( self [ old( reference. clone( ) ) ] . is_active( ) , "lineage was activated" ) ]
119114 #[ debug_ensures(
120- self[old(reference.clone())].location() == Some(&old(location.clone())),
121- "lineage was added to location"
122- )]
123- #[debug_ensures(
124- contract::explicit_lineage_store_lineage_at_location_contract(
125- self, old(reference.clone())
126- ), "lineage is at the location and index it references"
115+ self [ old( reference. clone( ) ) ] . indexed_location( ) == Some ( & old( indexed_location. clone( ) ) ) ,
116+ "lineage was added to indexed_location"
127117 ) ]
128- #[debug_ensures(
129- contract::explicit_lineage_store_invariant_contract(self, &old(location.clone())),
130- "maintains invariant of lineage-location bijection"
131- )]*/
132- fn insert_lineage_to_location_at_index (
118+ fn insert_lineage_to_indexed_location (
133119 & mut self ,
134120 reference : R ,
135- location : Location ,
136- index_at_location : usize ,
121+ indexed_location : IndexedLocation ,
137122 ) ;
138123
139124 #[ must_use]
140125 #[ debug_requires( self . get( reference. clone( ) ) . is_some( ) , "lineage reference is valid" ) ]
141126 #[ debug_requires( self [ reference. clone( ) ] . is_active( ) , "lineage is active" ) ]
142- /*#[debug_requires(
143- contract::explicit_lineage_store_lineage_at_location_contract(self, reference.clone()),
144- "lineage is at the location and index it references"
145- )]
146- #[debug_requires(
147- contract::explicit_lineage_store_invariant_contract(
148- self, self[reference.clone()].location().unwrap()
149- ), "invariant of lineage-location bijection holds"
150- )]
151- #[debug_ensures(
152- !contract::explicit_lineage_store_lineage_at_location_contract(
153- self, old(reference.clone())
154- ), "lineage was removed from the location and index it references"
155- )]
156- #[debug_ensures(
157- contract::explicit_lineage_store_invariant_contract(
158- self, &old(self[reference.clone()].location().unwrap().clone())
159- ), "maintains invariant of lineage-location bijection"
160- )]*/
127+ #[ debug_ensures( !self [ old( reference. clone( ) ) ] . is_active( ) , "lineage was deactivated" ) ]
161128 #[ debug_ensures(
162- ret == old( self [ reference. clone( ) ] . location ( ) . unwrap( ) . clone( ) ) ,
129+ ret == old( self [ reference. clone( ) ] . indexed_location ( ) . unwrap( ) . clone( ) ) ,
163130 "returns the individual's prior location"
164131 ) ]
165- fn extract_lineage_from_its_location ( & mut self , reference : R ) -> Location ;
132+ fn extract_lineage_from_its_location ( & mut self , reference : R ) -> IndexedLocation ;
166133}
0 commit comments