Skip to content

Commit 59b6b90

Browse files
committed
more
1 parent 1b342b9 commit 59b6b90

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

src/site_table.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,14 @@ impl SiteTable {
202202
/// * `Some(position)` if `row` is valid.
203203
/// * `None` otherwise.
204204
pub fn position<S: Into<SiteId> + Copy>(&self, row: S) -> Option<Position> {
205-
sys::tsk_column_access::<Position, _, _, _>(
206-
row.into(),
207-
self.as_ref().position,
208-
self.num_rows(),
209-
)
205+
assert!(self.num_rows() == 0 || !self.as_ref().position.is_null());
206+
unsafe {
207+
sys::tsk_column_access::<Position, _, _, _>(
208+
row.into(),
209+
self.as_ref().position,
210+
self.num_rows(),
211+
)
212+
}
210213
}
211214

212215
/// Get the ``ancestral_state`` value from row ``row`` of the table.
@@ -216,13 +219,20 @@ impl SiteTable {
216219
/// * `Some(ancestral state)` if `row` is valid.
217220
/// * `None` otherwise.
218221
pub fn ancestral_state<S: Into<SiteId>>(&self, row: S) -> Option<&[u8]> {
219-
sys::tsk_ragged_column_access(
220-
row.into(),
221-
self.as_ref().ancestral_state,
222-
self.num_rows(),
223-
self.as_ref().ancestral_state_offset,
224-
self.as_ref().ancestral_state_length,
225-
)
222+
assert!(
223+
(self.num_rows() == 0 && self.as_ref().ancestral_state_length == 0)
224+
|| (!self.as_ref().ancestral_state.is_null()
225+
&& !self.as_ref().ancestral_state_offset.is_null())
226+
);
227+
unsafe {
228+
sys::tsk_ragged_column_access(
229+
row.into(),
230+
self.as_ref().ancestral_state,
231+
self.num_rows(),
232+
self.as_ref().ancestral_state_offset,
233+
self.as_ref().ancestral_state_length,
234+
)
235+
}
226236
}
227237

228238
/// Retrieve decoded metadata for a `row`.

0 commit comments

Comments
 (0)