Closed oovm closed 3 years ago
By the way, I don't quite understand what value type specifically refers to.
TypeId(u64)
a value type?Finalize
?Regarding the value
wording/macro in the code. This is basically shorthand for "rust primitive type", since they all have the same properties. (Being bags of bits, with no interior mutability or other special properties.) It's more of a shortcut macro I wrote to simplify the implementation.
Outside this crate it's easier to use the derive rather than these special purpose shortcuts. I'd love to be able to make structural traits for shredder (where X would automatically get implemented for structs with all fields being X), but that isn't currently possible in Rust stable AFAIK
sync_value_type
Ok, this represents the primitive type, this macro should not be exported.
I was thinking about C# value types, -- the primitives and struct
in C#.
I think we do need a ValueType
trait to mark such types.
sync_vec_like
/sync_map_like
In fact, I also need this in my package.
I need to mark some third-party data structures with GC, eg: IndexMap
, SmallVec
.
(I cannot derive a structure in a third-party package)
I think this is necessary, but the name can indeed be changed.
Oh, forgot the second part, 😥😥😥.
The orphan rule also prohibits me from implementing third-party trait for third-party structures.
I think we do need a ValueType Trait to mark such types.
This is an interesting idea, but if you play with this, you'll notice that the blanket impls get rejected due to trait coherence rules. See: https://rust-lang.github.io/chalk/book/clauses/coherence.html
I need to mark some third-party data structures with GC, eg: IndexMap, SmallVec.
This may not work how you want, Rust prevents you from writing impl A for B
if you didn't own A or B in your crate. (See: the orphan rule.) This poses problems for all crates like shredder, since it makes it hard to be cross compatible with crates like SmallVec.
In your crate you can work around this by creating a struct that wraps SmallVec
, but derefs to SmallVec
as well. Also, for widely used crates like smallvec, I might be open to putting an impl in shredder behind a feature flag.
That being said, I'm not in principle opposed to making the macros public as long as unsafe
is in the name
Heh, you ninja'd my comment about the orphan rule
The primitive type
char
is obviously a value type.