Skip to content

Copy, Send and Sync for NodePtr and NodeIdx

Choose a tag to compare

@orxfun orxfun released this 23 Nov 16:56
· 7 commits to main since this release
f3c3c31

Changes

Implements Copy for NodePtr.

Implements Send and Sync for NodeIdx.

Carries out a major refactoring for pointers and indices passed as values rather than references.

Breaking Changes

This version introduces breaking changes due to the Copy implementation of the node pointer and node index. As recommended, their methods now take self rather than &self. Further, SelfRefCol that takes a node pointer or index as an argument now accept values by copy semantics rather than as references as in the prior version. Although this makes it more convenient to work with indices, it leads to compilation errors in the old code.

For instance, the following code block will not compile in the new version:

let col: SelfRefCol<_, _, _> = ...;
let idx: NodeIdx<_> = ...;

let node = col.node_from_idx(&idx); // error

It needs to be fixed as below:

let node = col.node_from_idx(idx);

Thanks to @hasezoey for suggestions and reviews.