|
| 1 | +# Migration guide |
| 2 | + |
| 3 | +This document helps with migration to newer versions of `tskit-rust`. |
| 4 | +This document will not be exhaustive. |
| 5 | +Rather, it will focus on highlights or "must know" items. |
| 6 | + |
| 7 | +Regarding breaking changes: |
| 8 | + |
| 9 | +* This document will discuss breaking changes requiring change in client code. |
| 10 | +* Other changes listed in the change log as breaking are considered "technically breaking |
| 11 | + but unlikely to affect anyone in practice". Please file an issue if we are wrong! |
| 12 | + |
| 13 | +Acronyms used: |
| 14 | + |
| 15 | +* UB = undefined behavior. |
| 16 | + |
| 17 | +## v0.11.0 |
| 18 | + |
| 19 | +### Bug fixes |
| 20 | + |
| 21 | +* Issue [363](https://github.com/tskit-dev/tskit-rust/issues/363), which was introduced in PR [300](https://github.com/tskit-dev/tskit-rust/pull/300). |
| 22 | + The bug resulted in UB when advancing trees for release builds. |
| 23 | + |
| 24 | +### Breaking changes |
| 25 | + |
| 26 | +#### New error variant. |
| 27 | + |
| 28 | +The error enum now includes `LibraryError`. |
| 29 | +Any code previously matching on errors will now break because the match is no longer exhaustive. |
| 30 | + |
| 31 | +#### Row getters |
| 32 | + |
| 33 | +This change occurred over several PR. |
| 34 | + |
| 35 | +All "getter" functions for table rows now return [`Option`](https://doc.rust-lang.org/std/option/enum.Option.html) instead of [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html) when a row index is out of bounds. |
| 36 | +These functions now return `None` for the out of bounds case. |
| 37 | +This behavior change brings the API in line with other rust APIs. |
| 38 | + |
| 39 | +To update: |
| 40 | + |
| 41 | +* If `None` should represent an error for your use case, use [`Option::ok_or_else`](https://doc.rust-lang.org/std/option/enum.Option.html#method.ok_or_else). |
| 42 | + In the case of a previous `Result<Option<_>, _>` that is now an `Option<Result<_, _>>`, use [`transpose`](https://doc.rust-lang.org/std/option/enum.Option.html#method.transpose). |
| 43 | + |
| 44 | +#### Lifetime annotations of table types |
| 45 | + |
| 46 | +PR [#373](https://github.com/tskit-dev/tskit-rust/pull/373). |
| 47 | + |
| 48 | +Previously, a non-owning view of an edge table had a type `EdgeTable<'a>`. |
| 49 | +Those lifetimes are no longer necessary, which is a big design win. |
| 50 | + |
| 51 | +Two traits, `TableAccess` and `NodeListRowGenerator`, have been removed. |
| 52 | +The `TableCollection` and `TreeSequence` types now contain that functionality as |
| 53 | +[`Deref`](https://doc.rust-lang.org/std/ops/trait.Deref.html) targets. |
| 54 | + |
| 55 | +Removing these traits implies: |
| 56 | + |
| 57 | +* Their removal from the crate prelude. |
| 58 | +* They can no longer be used as trait bounds. |
| 59 | + |
| 60 | +Some views of a node table that required mutability broke due to these changes. |
| 61 | +A new function in the `Deref` target is `nodes_mut(&mut self)` addresses this breakage. |
0 commit comments