Creation

We initialize a TableCollection with a sequence length. In tskit-c, the genome length is a C double. Here it is a newtype called tskit::Position:

    let sequence_length = tskit::Position::from(100.0);
    if let Ok(tables) = tskit::TableCollection::new(sequence_length) {
        assert_eq!(tables.sequence_length(), sequence_length);
        // In tskit, the various newtypes can be compared to
        // the low-level types they wrap.
        assert_eq!(tables.sequence_length(), 100.0);
    } else {
        panic!(
            "TableCollection creation sequence length = {} failed",
            sequence_length
        );
    }

The newtype pattern gives type safety by disallowing you to send a position to a function where a time is required, etc.. However, it can be inconvenient to type out the full type names every time. Thus, the API defines most functions taking arguments Into<T> where T is one of our newtypes. This design means that the following is equivalent to what we wrote above:

    let tables = tskit::TableCollection::new(100.0).unwrap();