Edit: if this is about MINOR leaking into PATCH, that’s not a problem since you can select a dependency version range (e.g. “2.0.0-rc, <2.1.0”)
Correct, this was my point. Pinning the exact version is simpler, but you can constrain the range like this as well to avoid semver issues.
However, by not pinning to an exact version, your reexport may vary between installs despite the user using the same v1.0.1 version of your package, which may be unexpected and arguably violates the purpose of having immutable versions in crates.io. The user can manually install both version 1.0.1 and, for example, version 2.0.0 to avoid it changing unexpectedly (though Cargo.lock will also prevent it from changing once it’s been set), but that makes less sense than just copying the struct to 1.0.1 rather than reexporting.
Plus, the whole point (in the article) was to make the transition easier within the ecosystem by avoiding a split between major versions. If v1.0.1 depends only on a subset of v2’s versions, then you still get a split between, say, [1.0.1, 2.1.0) and [2.1.0,).
However, by not pinning to an exact version, your reexport may vary between installs despite the user using the same v1.0.1 version of your package, which may be unexpected and arguably violates the purpose of having immutable versions in crates.io.
Re-exports exist outside of trick usage. num re-exports from num-* crates without exact version dependency restrictions, just to provide one major example.
If v1.0.1 depends only on a subset of v2’s versions, then you still get a split between, say, [1.0.1, 2.1.0) and [2.1.0,).
You can still release 1.1.x tracking 2.1.x, 1.2.x tracking 2.2.x, …etc to satisfy your restrictions 😉
But as the sibling comment pointed out. People don’t care about MINOR vs PATCH that much anyway. And the point of the trick is to smooth over a transition period, not keep the split forever.
under the assumption the struct previously had nonpublic members of course
Just for the sake of… exhaustiveness 😉, you can use #[non_exhaustive] on structs too.
Just for the sake of… exhaustiveness 😉, you can use #[non_exhaustive] on structs too.
I was under the impression that this worked on structs by creating hidden fields, though that might not/no longer be true. Anyway, this is why I felt no need to specify it.
Edit: Also, with regards to reexports, num crates are versioned separately and do different things. A better comparison is serde (which pins an exact serde_core version) or tokio (which uses a ~ specifier for its macros). rand relies on rand_core@^0.10.0, but these are 0.x so it’s still technically [0.10.0, 0.11.0) which isn’t as bad and hence why I changed the versions in my example.
Responding to the edit:
Correct, this was my point. Pinning the exact version is simpler, but you can constrain the range like this as well to avoid semver issues.
However, by not pinning to an exact version, your reexport may vary between installs despite the user using the same v1.0.1 version of your package, which may be unexpected and arguably violates the purpose of having immutable versions in crates.io. The user can manually install both version 1.0.1 and, for example, version 2.0.0 to avoid it changing unexpectedly (though
Cargo.lockwill also prevent it from changing once it’s been set), but that makes less sense than just copying the struct to 1.0.1 rather than reexporting.Plus, the whole point (in the article) was to make the transition easier within the ecosystem by avoiding a split between major versions. If v1.0.1 depends only on a subset of v2’s versions, then you still get a split between, say,
[1.0.1, 2.1.0)and[2.1.0,).Re-exports exist outside of trick usage.
numre-exports fromnum-*crates without exact version dependency restrictions, just to provide one major example.You can still release
1.1.xtracking2.1.x,1.2.xtracking2.2.x, …etc to satisfy your restrictions 😉But as the sibling comment pointed out. People don’t care about MINOR vs PATCH that much anyway. And the point of the trick is to smooth over a transition period, not keep the split forever.
Just for the sake of… exhaustiveness 😉, you can use
#[non_exhaustive]on structs too.I was under the impression that this worked on structs by creating hidden fields, though that might not/no longer be true. Anyway, this is why I felt no need to specify it.
Edit: Also, with regards to reexports,
numcrates are versioned separately and do different things. A better comparison isserde(which pins an exactserde_coreversion) ortokio(which uses a~specifier for its macros).randrelies onrand_core@^0.10.0, but these are0.xso it’s still technically[0.10.0, 0.11.0)which isn’t as bad and hence why I changed the versions in my example.