Closed jthulhu closed 2 years ago
Thanks @TheBlackBeans! Could you please add tests that validate that serialization/deserialization work? I would expect the following cases to be tested:
IntervalTree
: for both an empty tree and a populated tree of height >= 2
Node
: for both a leaf (i.e. no children) and an internal node (i.e. at least 1 child node)
@jonathanGB done. I also added deserialization-only tests, both for empty and non-empty trees, and for leaf and internal nodes.
Ops I didn't read the condition height ≥ 2, I'll patch that ASAP.
Alright now it should fit your requirements.
There we go.
Thanks!
FYI I noticed that we forgot to add the serde
feature in the Cargo.toml, thus users of the interval tree can't serialize/deserialize. It worked in the tests because the dependency is not optional in the dev-dependencies
.
This is fixed in https://github.com/jonathanGB/Unbounded-Interval-Tree/commit/3a8146dd710bae9fff6ddecac4d0dff93e1e5afb, and the new version is published on crates.io under version 1.1.2: https://crates.io/crates/unbounded-interval-tree/1.1.2.
@jonathanGB you don't need to specify a feature in this case. If a dependency is optional, it will automatically create a feature with the same name of the dependency, which will only enable that dependency. This is why in the code #[cfg(feature="serde")]
works without having to declare that feature. See the reference of this in the Cargo Book.
I added it as a plain dependency in dev mode simply because it's a pain to launch tests with --features serde
or similar stuff, and because my editor reports to me that some pieces of code are disabled if it has a #[cfg(feature="...")]
and that the feature is not enabled by default.
Also, I noticed that in the latest version of this package, you have moved UnboundedIntervalTree
inside the interval_tree
module, which is a breaking change, because now you have to use unbounded_interval_tree::interval_tree::IntervalTree
instead of unbounded_interval_tree::IntervalTree
, so maybe a major version bump would be necessary? Besides that, it's perfect, thanks for the merging the pull!
This commit add a feature "serde" (disabled by default) which pulls in the optional dependency serde and implements
Serialize
andDeserialize
forIntervalTree
.