Closed aatifsyed closed 1 year ago
forest have interest in const-construction of CIDs. See also https://github.com/multiformats/rust-cid/issues/138
I'd really like to avoid making a breaking change. Can we instead introduce a new function and deprecate wrap
? Such a new function can then have a different signature and introduce a new const
compatible error type.
I'd also like to see a test for this :)
- drop the illusion of
const
from thewrap
constructor. This is a breaking change
Why is that a breaking change. Given that it's not really const
, wouldn't removing the const
just be a bugfix? It shouldn't break any code as code using it as const wouldn't compile. What am I missing?
Why is that a breaking change. Given that it's not really const, wouldn't removing the const just be a bugfix? It shouldn't break any code as code using it as const wouldn't compile. What am I missing?
const calling the function would compile, but not accessing the result, so it's a breaking change
Closing - the constructors aren't unusable. Maybe there should be some user-facing documentation for the const
case so this issue isn't created again?
See https://github.com/multiformats/rust-multihash/pull/331#issuecomment-1660013138 for closing comment.
Multihash
's constructors areconst fn
, but they can't actually be used as such:Fails to compile:
This is presumably because the top level error type is non-copy/contains an io::Error which cannot be
const
https://github.com/multiformats/rust-multihash/blob/16e68d8203c787768688dab8aed4295a32f33bf0/src/error.rs#L42-L50Here is the source for the constructor https://github.com/multiformats/rust-multihash/blob/16e68d8203c787768688dab8aed4295a32f33bf0/src/multihash.rs#L59-L75
Fix is either:
const
from thewrap
constructor. This is a breaking changewrap
return a new, const-compatibleInvalidSize
error in its constructor. This is also a breaking change. This is my preference, and I'm happy to create a PR for such a change.