@@ -192,13 +192,23 @@ impl ProvenanceTable {
192192 /// # }
193193 /// ```
194194 pub fn timestamp < P : Into < ProvenanceId > + Copy > ( & self , row : P ) -> Option < & str > {
195- let timestamp_slice = sys:: tsk_ragged_column_access (
196- row. into ( ) ,
197- self . as_ref ( ) . timestamp ,
198- self . num_rows ( ) ,
199- self . as_ref ( ) . timestamp_offset ,
200- self . as_ref ( ) . timestamp_length ,
195+ assert ! (
196+ ( self . num_rows( ) != 0 && self . as_ref( ) . timestamp_length != 0 )
197+ || ( !self . as_ref( ) . timestamp. is_null( )
198+ && !self . as_ref( ) . timestamp_offset. is_null( ) )
201199 ) ;
200+
201+ // SAFETY: the previous assert checks the safety
202+ // requirements
203+ let timestamp_slice = unsafe {
204+ sys:: tsk_ragged_column_access (
205+ row. into ( ) ,
206+ self . as_ref ( ) . timestamp ,
207+ self . num_rows ( ) ,
208+ self . as_ref ( ) . timestamp_offset ,
209+ self . as_ref ( ) . timestamp_length ,
210+ )
211+ } ;
202212 match timestamp_slice {
203213 Some ( tstamp) => std:: str:: from_utf8 ( tstamp) . ok ( ) ,
204214 None => None ,
@@ -226,13 +236,22 @@ impl ProvenanceTable {
226236 /// # panic!("Expected Some(timestamp)");
227237 /// # }
228238 pub fn record < P : Into < ProvenanceId > + Copy > ( & self , row : P ) -> Option < & str > {
229- let record_slice = sys:: tsk_ragged_column_access (
230- row. into ( ) ,
231- self . as_ref ( ) . record ,
232- self . num_rows ( ) ,
233- self . as_ref ( ) . record_offset ,
234- self . as_ref ( ) . record_length ,
239+ assert ! (
240+ ( self . num_rows( ) != 0 && self . as_ref( ) . record_length != 0 )
241+ || ( !self . as_ref( ) . record. is_null( ) && !self . as_ref( ) . record_offset. is_null( ) )
235242 ) ;
243+
244+ // SAFETY: the previous assert checks the safety
245+ // requirements
246+ let record_slice = unsafe {
247+ sys:: tsk_ragged_column_access (
248+ row. into ( ) ,
249+ self . as_ref ( ) . record ,
250+ self . num_rows ( ) ,
251+ self . as_ref ( ) . record_offset ,
252+ self . as_ref ( ) . record_length ,
253+ )
254+ } ;
236255 match record_slice {
237256 Some ( rec) => std:: str:: from_utf8 ( rec) . ok ( ) ,
238257 None => None ,
0 commit comments